Manipulating data depending on ran changesets

I have the following problem: I want to write data into my database once a particular changeset ran, but the manipulation should’nt be made, if the changeset did not ran. I am using the following code:

final Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(new JdbcConnection(this.connection));
Liquibase liquibase = new Liquibase(“myFirstChangeLog.xml”, new ClassLoaderResourceAccessor(CsgApp.class.getClassLoader()), database);
liquibase.update("");
liquibase = new Liquibase(mySecondChangeLog.xml", new ClassLoaderResourceAccessor(CsgApp.class.getClassLoader()), database);
// changeExecListener
liquibase.update("");

I tried to use changeExecListener:

liquibase.setChangeExecListener(new ChangeExecListener() {

            @Override
            public void willRun(ChangeSet changeSet, DatabaseChangeLog databaseChangeLog, Database database, RunStatus runStatus) {
                System.out.println(“Will run changeset 2”);
            }

            @Override
            public void rolledBack(ChangeSet changeSet, DatabaseChangeLog databaseChangeLog, Database database) {
                // not used
            }

            @Override
            public void ran(ChangeSet changeSet, DatabaseChangeLog databaseChangeLog, Database database, ExecType execType) {
                System.out.println(“Ran changeset 2”);
            }
        });

but that wont work. Am I on the wrong way? How can I solve this problem?
 

What isn’t working? I’m not quite following what you are trying to do and what you are seeing happen.


Nathan

I want to insert a computed value into my database once a specific changeset ran. So I tried registering a ChangeExecListener hoping, that its method ‘ran’ is called after the changeset ran so I can code the calculation of the value in that method and then update the database. Sadly the method ‘ran’ is not called.

How are you registering the listener? In your example you just have "

Yes, I do. The latter code is inserted in the upper code at the position of the comment.

The listener works fine in my local testing, I’m not sure why it wouldn’t be for you. You aren’t seeing the println statemetns going at all?

Nathan