是否有支持继承策略 TABLE_PER_CLASS 的 EJB 单元测试库?

发布于 2024-12-05 05:09:51 字数 2910 浏览 2 评论 0原文

我有一个超级实体类,其继承策略 TABLE_PER_CLASS 在我的 EJB 项目中定义。我尝试使用 EJB3Unit 进行单元测试,但只是意识到 EJB3Unit 尚不支持继承策略 TABLE_PER_CLASS。还有其他支持它的测试库吗?我尝试用谷歌搜索,但没有任何结果......

Testsuite: entity.DepartmentTest
Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0 sec

------------- Standard Error -----------------
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Applications/NetBeans/glassfish-3.1.1/glassfish/modules/weld-osgi-bundle.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/Applications/NetBeans/glassfish-3.1.1/glassfish/modules/bean-validator.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: The requested version 1.5.10 by your slf4j binding is not compatible with [1.6]
SLF4J: See http://www.slf4j.org/codes.html#version_mismatch for further details.
------------- ---------------- ---------------
Null Test:  Caused an ERROR
null
null
java.lang.ExceptionInInitializerError
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:169)
Caused by: java.lang.RuntimeException: Inheritance strategy TABLE_PER_CLASS not (yet) supported.
    at com.bm.introspectors.EntityBeanIntrospector.processInheritance(EntityBeanIntrospector.java:475)
    at com.bm.introspectors.EntityBeanIntrospector.processAnnotations(EntityBeanIntrospector.java:160)
    at com.bm.introspectors.EntityBeanIntrospector.getEntityBeanIntrospector(EntityBeanIntrospector.java:90)
    at com.bm.introspectors.relations.RelationPropertyResolver.findAttributeForRelationAtOtherSide(RelationPropertyResolver.java:67)
    at com.bm.introspectors.AbstractPersistentClassIntrospector.processNonIdAnnotations(AbstractPersistentClassIntrospector.java:373)
    at com.bm.introspectors.AbstractPersistentClassIntrospector.processAnnotations(AbstractPersistentClassIntrospector.java:254)
    at com.bm.introspectors.AbstractPersistentClassIntrospector.processAccessTypeField(AbstractPersistentClassIntrospector.java:91)
    at com.bm.introspectors.EntityBeanIntrospector.processAccessTypeField(EntityBeanIntrospector.java:177)
    at com.bm.introspectors.EntityBeanIntrospector.processAnnotations(EntityBeanIntrospector.java:154)
    at com.bm.introspectors.EntityBeanIntrospector.getEntityBeanIntrospector(EntityBeanIntrospector.java:90)
    at com.bm.datagen.relation.BeanCollectionGenerator.<init>(BeanCollectionGenerator.java:94)
    at entity.DepartmentTest$MyEmoloyeeCreator.<init>(DepartmentTest.java:30)
    at entity.DepartmentTest$MyEmoloyeeCreator.<init>(DepartmentTest.java:27)
    at entity.DepartmentTest.<clinit>(DepartmentTest.java:19)


Test entity.DepartmentTest FAILED
test:
Deleting: /var/folders/xb/xbJfmQ0UGrCP0lmSoZFT4E+++TI/-Tmp-/TEST-entity.DepartmentTest.xml
BUILD SUCCESSFUL (total time: 8 seconds)

I have a super entity class with Inheritance strategy TABLE_PER_CLASS defined in my EJB project. I tried to use EJB3Unit for unit testing but only to realize that Inheritance strategy TABLE_PER_CLASS is not supported by EJB3Unit yet. Are there any other test libraries out there that support it? I tried to google but nothing came up...

Testsuite: entity.DepartmentTest
Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0 sec

------------- Standard Error -----------------
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Applications/NetBeans/glassfish-3.1.1/glassfish/modules/weld-osgi-bundle.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/Applications/NetBeans/glassfish-3.1.1/glassfish/modules/bean-validator.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: The requested version 1.5.10 by your slf4j binding is not compatible with [1.6]
SLF4J: See http://www.slf4j.org/codes.html#version_mismatch for further details.
------------- ---------------- ---------------
Null Test:  Caused an ERROR
null
null
java.lang.ExceptionInInitializerError
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:169)
Caused by: java.lang.RuntimeException: Inheritance strategy TABLE_PER_CLASS not (yet) supported.
    at com.bm.introspectors.EntityBeanIntrospector.processInheritance(EntityBeanIntrospector.java:475)
    at com.bm.introspectors.EntityBeanIntrospector.processAnnotations(EntityBeanIntrospector.java:160)
    at com.bm.introspectors.EntityBeanIntrospector.getEntityBeanIntrospector(EntityBeanIntrospector.java:90)
    at com.bm.introspectors.relations.RelationPropertyResolver.findAttributeForRelationAtOtherSide(RelationPropertyResolver.java:67)
    at com.bm.introspectors.AbstractPersistentClassIntrospector.processNonIdAnnotations(AbstractPersistentClassIntrospector.java:373)
    at com.bm.introspectors.AbstractPersistentClassIntrospector.processAnnotations(AbstractPersistentClassIntrospector.java:254)
    at com.bm.introspectors.AbstractPersistentClassIntrospector.processAccessTypeField(AbstractPersistentClassIntrospector.java:91)
    at com.bm.introspectors.EntityBeanIntrospector.processAccessTypeField(EntityBeanIntrospector.java:177)
    at com.bm.introspectors.EntityBeanIntrospector.processAnnotations(EntityBeanIntrospector.java:154)
    at com.bm.introspectors.EntityBeanIntrospector.getEntityBeanIntrospector(EntityBeanIntrospector.java:90)
    at com.bm.datagen.relation.BeanCollectionGenerator.<init>(BeanCollectionGenerator.java:94)
    at entity.DepartmentTest$MyEmoloyeeCreator.<init>(DepartmentTest.java:30)
    at entity.DepartmentTest$MyEmoloyeeCreator.<init>(DepartmentTest.java:27)
    at entity.DepartmentTest.<clinit>(DepartmentTest.java:19)


Test entity.DepartmentTest FAILED
test:
Deleting: /var/folders/xb/xbJfmQ0UGrCP0lmSoZFT4E+++TI/-Tmp-/TEST-entity.DepartmentTest.xml
BUILD SUCCESSFUL (total time: 8 seconds)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

玩心态 2024-12-12 05:09:51

也许看看 OpenEJB。这是一个使用 JPA 的示例。我不知道它是否涵盖了您的确切场景,但应该足够接近。

请注意,下载页面上有一个示例 zip 文件,其中还有大约两打类似的示例。所有这些都是单元测试,几乎涵盖了 EJB API 的全部范围,包括 MDB、Web 服务、事务、安全性,当然还有 JPA、数据源等基本内容。

Maybe check out OpenEJB. Here is an example that uses JPA. I don't know if it covers your exact scenario, but should be close enough.

Note there is an examples zip file on the download page that has about two dozen more examples like that one. All of them are unit tests and they cover pretty much the full spectrum of the EJB API including MDBs, Web Services, Transactions, Security and of course basic things like JPA, DataSources, etc.

夜无邪 2024-12-12 05:09:51

现在已经可以了。您应该检查:

文档上的 EJB3 实体中的每个类继承表.jboss.org

代码示例:

@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public class Pet implements java.io.Serializable
{

...

}   

希望对您有所帮助。

It does by now. You should check:

Table per Class inheritance in EJB3 Entities on docs.jboss.org

Code sample:

@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public class Pet implements java.io.Serializable
{

...

}   

I hope I helped.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文