Spring PersistenceUnitPostProcessor的Seam等效项 [英] Seam Equivalent of Spring PersistenceUnitPostProcessor

查看:102
本文介绍了Spring PersistenceUnitPostProcessor的Seam等效项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们通过Spring/Hibernate使用JPA进行了非常舒适的设置,在该过程中,我们将PersistenceUnitPostProcessor附加到我们的实体管理器工厂,此后处理器获取项目名称列表,扫描类路径以查找包含该名称的jar,然后添加这些jar文件,用于将实体扫描到持久性单元,这比在persistence.xml中指定要方便得多,因为它可以使用部分名称,并且我们添加了用于在战争中进行检测(单元测试)时检测不同类路径配置的功能,耳朵等

We have a very comfortable setup using JPA through Spring/Hibernate, where we attach a PersistenceUnitPostProcessor to our entity manager factory, and this post processor takes a list of project names, scans the classpath for jars that contain that name, and adds those jar files for scanning for entities to the persistence unit, this is much more convenient than specifying in persistence.xml since it can take partial names and we added facilities for detecting the different classpath configurations when we are running in a war, a unit test, an ear, etc.

现在,我们正在尝试将Spring替换为Seam,但我找不到能够实现相同挂钩机制的工具.一种解决方案是尝试使Seam挂在Spring上,但是该解决方案在我们的环境中还有其他缺点.所以我的问题是:有人可以将我指向Seam中的此类设施(如果存在的话),或者如果我打算修补Seam,至少应该在代码中应该查找的地方?

Now, we are trying to replace Spring with Seam, and I cant find a facility to accomplish the same hooking mechanism. One Solution is to try and hook Seam through Spring, but this solution has other short-comings on our environment. So my question is: Can someone point me to such a facility in Seam if exists, or at least where in the code I should be looking if I am planning to patch Seam?

谢谢.

推荐答案

如果您在JBoss 6之类的Java EE容器中运行(我真的建议这样做),那么您所要做的就是将您的bean打包到一个jar中,将META-INF/persistence.xml放入其中,然后将罐子放入WAR或EAR包中.罐中所有@Entity注释的bean都将被处理.

If you're running in a Java EE container like JBoss 6 (and I really recommend so), all you need is to package your beans into a jar, place a META-INF/persistence.xml inside it and place the jar into your WAR or EAR package. All @Entity annotated beans inside the jar will be processed.

对于单元测试,您可以将<jar-file>元素指向生成的.class输出目录,并且Hibernate还将选择Entities.甚至在运行时使用Ejb3Configuration.addAnnotatedClass;

For unit-testing, you could point the <jar-file> element to the generated .class output directory and Hibernate will also pick the Entities. Or even configure during runtime using Ejb3Configuration.addAnnotatedClass;

@see http://docs.jboss .org/hibernate/entitymanager/3.6/reference/en/html/configuration.html

这篇关于Spring PersistenceUnitPostProcessor的Seam等效项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆