Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mixing EJB 2.x BMP entity beans with Hibernate 3.x

I have a large application that uses EJB 2.x entity beans (BMP). This is well-known to be a horrible persistence strategy (I can elaborate if necessary).

I'd like to start migrating this application to use a much more expressive, transparent, and non-invasive persistence strategy, and given my company's previous experience with it, Hibernate 3.x is the obvious choice.

Migrating to Hibernate is going to take a while, as over 100 tables in the application use entity beans. So I'm looking at a phased approach where the two persistence strategies run in parallel, ideally on the same tables at the same time, if possible.

My question is, what are the pitfalls (if any) of combining these two persistence strategies? Will they get in each other's way?

like image 762
Andrew Swan Avatar asked Sep 16 '08 01:09

Andrew Swan


People also ask

What is entity bean in hibernate?

Entity bean represents the persistent data stored in the database. It is a server-side component. In EJB 2. x, there was two types of entity beans: bean managed persistence (BMP) and container managed persistence (CMP).

Does @entity create a bean?

@Entity declares the class as an entity bean (i.e. a persistent POJO class), @Id declares the identifier property of this entity bean.

Which annotation is used on model classes to specify they are entity beans?

In entity bean code, you designate CMP fields with the @CmpField annotation.


1 Answers

As said jodonnel, you have to pay attention to caching, because if you use second-level caching in Hibernate and a table is modified outside of Hibernate, then Hibernate has no way to know that its cache entry is stale.

For the transactions, they should both use JTA provided by the container, so for that it should be safe.

like image 129
Damien B Avatar answered Oct 09 '22 13:10

Damien B