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?
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).
@Entity declares the class as an entity bean (i.e. a persistent POJO class), @Id declares the identifier property of this entity bean.
In entity bean code, you designate CMP fields with the @CmpField annotation.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With