Bootstrap EJB3 application before JPA / Hibernate startup
Asked Answered
D

1

1

I have an EJB3 project (EAR packaging of JARs, no WARs) that I'm trying to integrate Flyway (database migrations) into.

I've tried a couple of options to create a hook where I can run code before Hibernate starts doing its thing (binding to entities etc);

  • Using the @StartUp annotation. This unfortunately gets run AFTER the JPA startup.
  • ServletContextListener / @WebListener. But of course you need a WEB-INF/ directory for that to work.
  • Looked at using the @DependsOn annotation to see if I could get a class to run before Hibernate, but couldn't get that to work.
  • I'm on Hibernate 3.6 at the moment, bumping to Hibernate 4 (and thus getting the Integrator API) is not really an option.

Do I have any other options?

Dropline answered 28/8, 2014 at 20:58 Comment(0)
V
0

I do think that If you do not want to JPA to start you will need to use RESOURCE_LOCAL transaction with non-jta-datasource.

If you use any kind of JTA transactions the JPA will be eagerly invoked.

Like this the JPA will only be invoked when you start a transaction, but you will need to control it manually.

Valles answered 29/8, 2014 at 1:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.