3

We use EJB2.x entity beans with BMP (bean managed persistence). It appears BMP is not supported in EJB3. We had wanted to stay current and upgrade to EJB3. Does anyone know if there are in fact any BMP options available in 3.0?

From what I can tell, using 3.0, all entity beans have to use JPA and by definition ORM. There are some options to use native SQL but that is still just a way to use JPA to implement ORM.

I wasn't sure if there is another EJB3 approach to achieve the same functionality as with EJB2.x BMP entity beans. We currently use the standard ejbStore method to update the DB through native SQL and the ejbLoad method to lookup all beans and to refresh the bean in the event of a transaction rollback. I thought you might be able to do this with EJB3 session beans but I wasn't sure.

Perhaps instead of migrating to EJB3 beans we should migrate to Spring.

Pascal Thivent
  • 562,542
  • 136
  • 1,062
  • 1,124
Marcus Leon
  • 55,199
  • 118
  • 297
  • 429
  • Spring and EJB3 aren't necessarily mutually exclusive. What part of Spring are you talking about? It's a big framework, and you aren't forced to use all of it at once. – Andrew Swan May 21 '09 at 08:56
  • 2
    Btw, we use BMP 2.1 too, and I feel your pain. I think the reason you're having trouble finding something similar in a modern API is that people have realised that hand-coding SQL is a bad idea when we have many ORM libraries that will generate the queries for you in a db-agnostic way (you only need to specify the db dialect). – Andrew Swan May 21 '09 at 08:58

2 Answers2

0

If you really want to code SQL by hand, go for POJOs and raw JDBC DAOs. But this is also maybe an opportunity to rethink the way you're doing things and embrace ORM/JPA.

Pascal Thivent
  • 562,542
  • 136
  • 1,062
  • 1,124
0

In the past, I have mixed Hibernate + EJB2 (CMP + BMP) sharing transactional contexts with no issues, using JTA.

This problem is quite similar... Take a look at https://cwiki.apache.org/GMOxDOC22/developing-bean-managed-persistence-with-jpa.html. You can implement your own EntityManager.

With luck, you may be even able to share transactional contexts.

Sebastian
  • 1,835
  • 3
  • 22
  • 34