views:

32

answers:

1

I manage to issue a Liquibase Update as described in Liquibase Servlet Listener.

<listener>
    <listener-class>liquibase.servlet.LiquibaseServletListener</listener-class>
</listener>

This effectively executes my Changelog.

However, this happens after the setup of the EntityManager. Obviously, this is too late if I want my Persistence provider to validate the database schema:

   <property name="hibernate.hbm2ddl.auto" value="validate"/>

... the tables simply do not exist yet.

Is there a way I can make Liquibase to Update the database schema, before the EntityManager is initialized?

PS:AppServer is JBoss6

=========================[ UPDATE ]===========================

Based on the brief discussion with Nathan below, I may have to rephrase the question as follows:

Does anybody know a code hook in the JBoss startup sequence before the initialization of the EntityManager?

If that exists, I can move the Liquibase update logic to that place?

A: 

Is your EntityManager started in a listener as well (such as spring's listener)?

Usually app servers start listeners in the order they are listed in your web.xml file, make sure your liquibase listener is listed before whatever starts hibernate.

Nathan Voxland
The PersistenceUnit (and associated EntityManager) are started early in the JBOSS boot-process. Only after that, the web-apps are initialized... 8-/
Jan