迁移EJB2.x BMP实体bean

时间:2022-09-11 13:53:41

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?

我们将EJB2.x实体bean与BMP(bean管理持久性)一起使用。看来EJB3中不支持BMP。我们希望保持最新状态并升级到EJB3。有谁知道3.0中是否有任何BMP选项?

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.

据我所知,使用3.0,所有实体bean都必须使用JPA和定义ORM。有一些选项可以使用本机SQL,但这仍然只是一种使用JPA实现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.

我不确定是否有另一种EJB3方法可以实现与EJB2.x BMP实体bean相同的功能。我们目前使用标准的ejbStore方法通过本机SQL和ejbLoad方法更新数据库,以查找所有bean并在事务回滚时刷新bean。我以为你可以用EJB3会话bean做到这一点,但我不确定。

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

也许我们应该迁移到Spring,而不是迁移到EJB3 bean。

2 个解决方案

#1


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.

如果您真的想手动编写SQL,请转到POJO和原始JDBC DAO。但这也许是一个重新思考你做事和接受ORM / JPA的机会。

#2


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

在过去,我使用JTA混合了Hibernate + EJB2(CMP + BMP)共享事务上下文,没有任何问题。

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.

这个问题非常相似......请查看https://cwiki.apache.org/GMOxDOC22/developing-bean-managed-persistence-with-jpa.html。您可以实现自己的EntityManager。

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

幸运的话,您甚至可以共享交易上下文。

#1


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.

如果您真的想手动编写SQL,请转到POJO和原始JDBC DAO。但这也许是一个重新思考你做事和接受ORM / JPA的机会。

#2


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

在过去,我使用JTA混合了Hibernate + EJB2(CMP + BMP)共享事务上下文,没有任何问题。

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.

这个问题非常相似......请查看https://cwiki.apache.org/GMOxDOC22/developing-bean-managed-persistence-with-jpa.html。您可以实现自己的EntityManager。

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

幸运的话,您甚至可以共享交易上下文。