1. We have a system in which 2 applications share the same database instance. Application 1 uses BC4J, while Application 2 uses Toplink/JPA. Because of the Toplink cache, all the changes persisted to DB done by Application 1 is not recognized by Application 2, unless we bounce the Application 2 server, or we wait for a long time. I guess this is a common problem that others encountered before. Please share your advice on this problem. Continue reading
In recent past I was having a discussion with a person from a large MNC who wondered when I told that I have used Hibernate with EJB 3 entity beans , then asked me the significance of using such configuration. Well, I tried my level-best to make him understand that, but alas! the person who is not even aware of JPA spec and tied up with Java EE 1.4 with Weblogic and WebSphere, how can I make him understand!
Well, if you are aware of Java EE 6, EJB 3 Spec, JPA then and only then read ahead, else it will be wastage of your time.
Hibernate also support Entity beans and Java Persistence Provider(JPA) of EJB3.0+ specification. In fact many of the concepts of Entity beans has been taken from Hibernate. JBoss application server uses Hibernate as the default persistence provider for Entity beans and JPA. JPA has the notion of persistence unit which represents the configuration.
EntityManagerFactory of JPA corresponds to SessionFactory and EntityManager corresponds to Session.
Basically, EJB 3, JPA are spec and Hibernate is an implementation of JPA spec[ as TopLink, EclipseLink etc] so, if Entity Beans can use JPA then the underlying implementation could be be any JPA provider e.g. Hibernate,TopLink, EclipseLink etc.
Now, let me answer the second question: Significance of using Hibernate[JPA] with Entity Beans.
- You are free from any Vendor-LockIn, change your JPA implementation when-ever you need it.
- You are free to change your DataBase provider at any point of time with-out changing a single line of code[ except orm.xml or persistence.xml file]
- Even you can use the bean validation features of Entity beans with Hibernate validator.
- Use features like dynamic queries and named queries , which will be a really helpful if concurrency and application performance are of your concern.
- As well as most of the features of ORM tools are readily available.