开发者

Any EJB unit test library that supports Inheritance strategy TABLE_PER_CLASS?

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:4开发者_JS百科75)
    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)


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜