0

I recently migrated my application from using Hibernate 3.5.4 to 5.2.4. I replaced library jars, made modifications to my code to work with 5.2.4 using legacy bootstrapping, legacy domain model (hbm.xml), HQL and legacy criteria query, and all went well.

Now I'm considering updating my code to use JPA APIs and wondering how to proceed because there are so much code that I can't update all at once.

  1. Do I need to use JPA bootstrapping before using any of JPA APIs? or Can I just use Session for JPA operations because Session extends EntityManager?

  2. Is it okay to mix hibernate queries and JPA queries in a single Session? Does caching mechanism work correctly?

  3. Is there a recommended path for migration order? For example, legacy to JPA bootstrapping first, then hbm.xml to annotation-based, then HQL to JPQL, then legacy criteria query to JPA criteria query... Or is it okay to migrate in any order?

apptaro
  • 279
  • 2
  • 8
  • 1. You can switch to JPA bootstrapping and you will still be able to use the hibernate-only API, but I don't know if the it works in the other direction. It should. 2. I believe JPQL and HSQL queries are created by the same API. – coladict Nov 01 '16 at 09:38
  • What I have found so far: 1. JPA bootstrapping should be needed to use JPA because some JPA functionality does not work with native bootstrapping: [link](http://stackoverflow.com/q/28340507/1837675) 2. entityManager.unwrap(Session.class) == session (tested with Hibernate 5.2.4) so it should work fine, but I have not tested yet. – apptaro Nov 07 '16 at 08:31
  • What I have found so far: 3. hibernate.cfg.xml, *.hbm.xml, mapping annotations all work with both native bootstrapping and JPA bootstrapping, so you can leave them as it is while you migrate native bootstrapping to JPA bootstrapping, which force you to work some issues out if you use Interceptor, custom type mapping, event listeners, etc. – apptaro Nov 07 '16 at 08:44

0 Answers0