-
1. Re: How to run code before JPA startup?
nickarls Apr 24, 2010 9:31 PM (in response to bobthule)Isn't the boot order pretty much appserver-specific? What is it in JBoss? CDI/JSF/JPA?
-
2. Re: How to run code before JPA startup?
mwohlf Apr 24, 2010 10:05 PM (in response to bobthule)take a look at liquibase if you want to do database upgrades/checks on startup
-
3. Re: How to run code before JPA startup?
bobthule Apr 25, 2010 4:37 PM (in response to bobthule)Good point about the appserver-specific. It will be CDI/JSF/JPA all deployed in a single war file. It will be deployed on JBoss but in the future for other clients it may need to be deployed on Glassfish or Tomcat.
I looked at liquibase and they use a ServletListener to do the updates at startup, but I am unclear whether that doing it that way is guaranteed to run before JPA starts up.
It seems like JPA and/or Hibernate would have a hook to run code before it starts up but I couldn't find anything on that. I also looked to see if Weld had a way, but I couldn't find it, either.
I would most prefer a solution with Weld.
-
4. Re: How to run code before JPA startup?
pmuir Apr 26, 2010 12:47 PM (in response to bobthule)If you are on JBoss AS and just want to run SQL, Hibernate will execute the import.sql AFTER JPA gets set up.
You can't guarantee any ordering that I know of, and I don't know of a hook to do this.
-
5. Re: How to run code before JPA startup?
bobthule Apr 26, 2010 4:08 PM (in response to bobthule)Thanks Pete,
Yeah I know about import.sql, but the goal is more to help ease customer installations by allowing database schema migrations to automatically run when the website starts up.
I had an idea of creating my own PersistenceProvider and overriding the methods to do my upgrades and then passing off to the Hibernate PersistenceProvider.