What can you do currently with EJB3 and EJB21?
- .ejb3 jars support EJB 2.1 Session and MDBs, but not EJB 2.x Entity beans deployed in the same jar. We will eventually ahve to support this, but for now, our EJB3 container does not support EJB 2.x CMP or BMP.
- You can deploy EJB3 jars and EJB 2.1 jars in the same EAR file. You should also be able to reference EJB3 from EJB 21 and viceversa. We have some unit tests for that. If you find problems in that arena, please post the issues on Jira with small test cases so that we can easily reproduce.
- The Specification has some EJB3/2.1 integration requirements for session beans. Basically it allows you to have an EJB3 session bean, but the client be an old 2.1 style bean. Basically an EJB3 is allowed to have a home interface if you want to.
What you cannot do is:
- Mix CMP and EJB3 persistence together. EJB3 entities and CMP entities will not be aware of one another and it will be very dangerous for you to have a mix there. I suggest migrating your CMP stuff to EJB3 persistence or putting the write facade abstractions in from of your data objects so that it doesn't matter.
I've had similar questions regarding a mix of JDBC and EJB 3.0 -- the root question of all of this is, can we gradually convert our JDBC code to EJB 3.0, or do we have to have a 'big bang' event where everything gets migrated at once?
Some of the possible scenarios would be:
- Do a table-by-table migration. So some tables would be fully EJB 3.0, while others remain fully JDBC. If a EJB 3.0 entity bean has a reference to a class still using JDBC persistence, I'm not sure what we would do -- doesn't seem like it would be possible to model the relationship with @OneToOne (or whatever multiplicity is correct), but I'm not sure what happens if we try to persist an object reference that doesn't include any such annotation.
- Move all of the create/update/delete methods to EJB 3.0 first, and then migrate the queries later. This way any referential integrity issues would be resolved, queries might get stale data.
Is there any generally accepted best practice for how to go about such a migration?
Can anybody confirm the current state of the world with this issue please?
The above seems to indicate that you can deploy EJB 2 and EJB 3 in the same EAR file (got that working), and even talk to each other through Session Beans. But what I really want to confirm is whether CMR between EJB 2 / EJB3 entity beans is at all possible? (to allow a gradual incremental update of EJB2 to EJB3 without doing a big bang conversion of the whole lot). Bill Burkes comment implies this is not possible but the post is getting on for 2 years old now!