Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: 3.1 beta1
Hibernate Annotations version: 3.1 beta4
EJB Presistence: Public Review
Full stack trace of any exception that occurs:
Code:
2005-08-08 18:08:812 [main] DEBUG com.dolby.pics.core.db.model.impl.BaseDAO [beginTransaction() :43] - com.dolby.pics.core.db.model.impl.BaseDAO trying to start a transaction
2005-08-08 18:08:873 [main] INFO org.hibernate.cfg.Environment [<clinit>() :464] - Hibernate 3.1 beta 1
2005-08-08 18:08:883 [main] INFO org.hibernate.cfg.Environment [<clinit>() :477] - hibernate.properties not found
2005-08-08 18:08:891 [main] INFO org.hibernate.cfg.Environment [<clinit>() :510] - using CGLIB reflection optimizer
2005-08-08 18:08:893 [main] INFO org.hibernate.cfg.Environment [<clinit>() :540] - using JDK 1.4 java.sql.Timestamp handling
2005-08-08 18:08:319 [main] INFO org.hibernate.cfg.Configuration [configure() :1148] - configuring from resource: /hibernate-test.cfg.xml
2005-08-08 18:08:361 [main] INFO org.hibernate.cfg.Configuration [getConfigurationInputStream() :1116] - Configuration resource: /hibernate-test.cfg.xml
2005-08-08 18:08:727 [main] DEBUG org.hibernate.util.DTDEntityResolver [resolveEntity() :42] - trying to locate http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd in classpath under org/hibernate/
2005-08-08 18:08:730 [main] DEBUG org.hibernate.util.DTDEntityResolver [resolveEntity() :53] - found http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd in classpath
2005-08-08 18:08:887 [main] DEBUG org.hibernate.cfg.Configuration [addProperties() :1100] - hibernate.connection.username=zpics
2005-08-08 18:08:889 [main] DEBUG org.hibernate.cfg.Configuration [addProperties() :1100] - hibernate.connection.password=rrr@pf0p
2005-08-08 18:08:890 [main] DEBUG org.hibernate.cfg.Configuration [addProperties() :1100] - hibernate.dialect=org.hibernate.dialect.DerbyDialect
2005-08-08 18:08:891 [main] DEBUG org.hibernate.cfg.Configuration [addProperties() :1100] - hibernate.connection.url=jdbc:derby:target/zpics;create=true
2005-08-08 18:08:892 [main] DEBUG org.hibernate.cfg.Configuration [addProperties() :1100] - hibernate.connection.driver_class=org.apache.derby.jdbc.EmbeddedDriver
2005-08-08 18:08:893 [main] DEBUG org.hibernate.cfg.Configuration [addProperties() :1100] - hibernate.show_sql=true
2005-08-08 18:08:894 [main] DEBUG org.hibernate.cfg.AnnotationConfiguration [parseMappingElement() :319] - null<-org.dom4j.tree.DefaultAttribute@1c5d9084 [Attribute: name class value "com.dolby.pics.core.db.model.util.EntityObject"]
2005-08-08 18:08:944 [main] DEBUG org.hibernate.cfg.AnnotationConfiguration [parseMappingElement() :319] - null<-org.dom4j.tree.DefaultAttribute@203fa5ac [Attribute: name class value "com.dolby.pics.core.db.model.util.EntityWithGeneratedId"]
2005-08-08 18:08:946 [main] DEBUG org.hibernate.cfg.AnnotationConfiguration [parseMappingElement() :319] - null<-org.dom4j.tree.DefaultAttribute@979dce4 [Attribute: name class value "com.dolby.pics.core.db.model.util.EntityWithAssignedId"]
2005-08-08 18:08:947 [main] DEBUG org.hibernate.cfg.AnnotationConfiguration [parseMappingElement() :319] - null<-org.dom4j.tree.DefaultAttribute@1f950198 [Attribute: name class value "com.dolby.pics.core.db.model.impl.BusinessUnit"]
2005-08-08 18:08:948 [main] DEBUG org.hibernate.cfg.AnnotationConfiguration [parseMappingElement() :319] - null<-org.dom4j.tree.DefaultAttribute@6f9bb25a [Attribute: name class value "com.dolby.pics.core.db.model.impl.MasterProduct"]
2005-08-08 18:08:949 [main] DEBUG org.hibernate.cfg.AnnotationConfiguration [parseMappingElement() :319] - null<-org.dom4j.tree.DefaultAttribute@56da6bf4 [Attribute: name class value "com.dolby.pics.core.db.model.impl.MasterDolbyProduct"]
2005-08-08 18:08:950 [main] DEBUG org.hibernate.cfg.AnnotationConfiguration [parseMappingElement() :319] - null<-org.dom4j.tree.DefaultAttribute@1de58cb8 [Attribute: name class value "com.dolby.pics.core.db.model.impl.MasterKitProduct"]
2005-08-08 18:08:951 [main] DEBUG org.hibernate.cfg.AnnotationConfiguration [parseMappingElement() :319] - null<-org.dom4j.tree.DefaultAttribute@4cb9e45a [Attribute: name class value "com.dolby.pics.core.db.model.impl.MasterNonDolbyProduct"]
2005-08-08 18:08:971 [main] DEBUG org.hibernate.cfg.AnnotationConfiguration [parseMappingElement() :319] - null<-org.dom4j.tree.DefaultAttribute@254e8cee [Attribute: name class value "com.dolby.pics.core.db.model.impl.Country"]
2005-08-08 18:08:972 [main] DEBUG org.hibernate.cfg.AnnotationConfiguration [parseMappingElement() :319] - null<-org.dom4j.tree.DefaultAttribute@1ebcda2d [Attribute: name class value "com.dolby.pics.core.db.model.impl.SubSystem"]
2005-08-08 18:08:974 [main] DEBUG org.hibernate.cfg.AnnotationConfiguration [parseMappingElement() :319] - null<-org.dom4j.tree.DefaultAttribute@6ee0a386 [Attribute: name class value "com.dolby.pics.core.db.model.impl.InstalledSubSystem"]
2005-08-08 18:08:976 [main] DEBUG org.hibernate.cfg.AnnotationConfiguration [parseMappingElement() :319] - null<-org.dom4j.tree.DefaultAttribute@671ff436 [Attribute: name class value "com.dolby.pics.core.db.model.impl.Address"]
2005-08-08 18:08:978 [main] DEBUG org.hibernate.cfg.AnnotationConfiguration [parseMappingElement() :319] - null<-org.dom4j.tree.DefaultAttribute@651dba45 [Attribute: name class value "com.dolby.pics.core.db.model.impl.MapicsAddress"]
2005-08-08 18:08:980 [main] DEBUG org.hibernate.cfg.AnnotationConfiguration [parseMappingElement() :319] - null<-org.dom4j.tree.DefaultAttribute@2af081 [Attribute: name class value "com.dolby.pics.core.db.model.impl.MaximizerAddress"]
2005-08-08 18:08:981 [main] DEBUG org.hibernate.cfg.AnnotationConfiguration [parseMappingElement() :319] - null<-org.dom4j.tree.DefaultAttribute@7ec5495e [Attribute: name class value "com.dolby.pics.core.db.model.impl.PeoplesoftAddress"]
2005-08-08 18:08:983 [main] DEBUG org.hibernate.cfg.AnnotationConfiguration [parseMappingElement() :319] - null<-org.dom4j.tree.DefaultAttribute@4f9a32e0 [Attribute: name class value "com.dolby.pics.core.db.model.impl.Product"]
2005-08-08 18:08:985 [main] DEBUG org.hibernate.cfg.AnnotationConfiguration [parseMappingElement() :319] - null<-org.dom4j.tree.DefaultAttribute@716925b0 [Attribute: name class value "com.dolby.pics.core.db.model.impl.EntityType"]
2005-08-08 18:08:986 [main] DEBUG org.hibernate.cfg.AnnotationConfiguration [parseMappingElement() :319] - null<-org.dom4j.tree.DefaultAttribute@26914f6a [Attribute: name class value "com.dolby.pics.core.db.model.impl.InventoryItem"]
2005-08-08 18:08:988 [main] DEBUG org.hibernate.cfg.AnnotationConfiguration [parseMappingElement() :319] - null<-org.dom4j.tree.DefaultAttribute@42787d6a [Attribute: name class value "com.dolby.pics.core.db.model.impl.customfield.AbstractCFType"]
2005-08-08 18:08:990 [main] DEBUG org.hibernate.cfg.AnnotationConfiguration [parseMappingElement() :319] - null<-org.dom4j.tree.DefaultAttribute@5f326484 [Attribute: name class value "com.dolby.pics.core.db.model.impl.customfield.AbstractMultiFieldCFType"]
2005-08-08 18:08:991 [main] DEBUG org.hibernate.cfg.AnnotationConfiguration [parseMappingElement() :319] - null<-org.dom4j.tree.DefaultAttribute@5c1428ea [Attribute: name class value "com.dolby.pics.core.db.model.impl.customfield.MultiSelectCFType"]
2005-08-08 18:08:993 [main] DEBUG org.hibernate.cfg.Configuration [parseListener() :1340] - Encountered configured listener : pre-insert=com.dolby.pics.core.db.model.util.CorePreInsertEventListener
2005-08-08 18:08:994 [main] DEBUG org.hibernate.cfg.Configuration [parseListener() :1340] - Encountered configured listener : pre-update=com.dolby.pics.core.db.model.util.CorePreUpdateEventListener
2005-08-08 18:08:996 [main] INFO org.hibernate.cfg.Configuration [doConfigure() :1259] - Configured SessionFactory: null
2005-08-08 18:08:999 [main] DEBUG org.hibernate.cfg.Configuration [doConfigure() :1260] - properties: {hibernate.connection.password=rrr@pf0p, java.runtime.name=Java(TM) 2 Runtime Environment, Standard Edition, sun.boot.library.path=/usr/local/apps/inst/java/jdk1.5.0_04/jre/lib/amd64, java.vm.version=1.5.0_04-b05, hibernate.connection.username=zpics, java.vm.vendor=Sun Microsystems Inc., java.vendor.url=http://java.sun.com/, path.separator=:, java.vm.name=Java HotSpot(TM) 64-Bit Server VM, file.encoding.pkg=sun.io, user.country=GB, sun.os.patch.level=unknown, java.vm.specification.name=Java Virtual Machine Specification, user.dir=/home/djb/workspaces/eclipse-SDK-3.1/workspace/pics-core-db-model, java.runtime.version=1.5.0_04-b05, java.awt.graphicsenv=sun.awt.X11GraphicsEnvironment, java.endorsed.dirs=/usr/local/apps/inst/java/jdk1.5.0_04/jre/lib/endorsed, os.arch=amd64, java.io.tmpdir=/tmp, line.separator=
, java.vm.specification.vendor=Sun Microsystems Inc., os.name=Linux, sun.jnu.encoding=UTF-8, java.library.path=/usr/local/apps/inst/java/jdk1.5.0_04/jre/lib/amd64/server:/usr/local/apps/inst/java/jdk1.5.0_04/jre/lib/amd64:/usr/local/apps/inst/java/jdk1.5.0_04/jre/../lib/amd64:/usr/lib/mozilla/, java.specification.name=Java Platform API Specification, java.class.version=49.0, sun.management.compiler=HotSpot 64-Bit Server Compiler, os.version=2.6.10-5-amd64-generic, user.home=/home/djb, user.timezone=Europe/London, java.awt.printerjob=sun.print.PSPrinterJob, file.encoding=UTF-8, java.specification.version=1.5, hibernate.connection.driver_class=org.apache.derby.jdbc.EmbeddedDriver, user.name=djb, java.class.path=/home/djb/workspaces/eclipse-SDK-3.1/workspace/pics-core-db-model/bin:/home/djb/maven/repository/antlr/jars/antlr-2.7.5H3.jar:/home/djb/maven/repository/asm/jars/asm-1.5.3.jar:/home/djb/maven/repository/asm/jars/asm-attrs-1.5.3.jar:/home/djb/maven/repository/commons-lang/jars/commons-lang-2.0.jar:/home/djb/maven/repository/commons-logging/jars/commons-logging-1.0.4.jar:/home/djb/maven/repository/commons-collections/jars/commons-collections-3.1.jar:/home/djb/maven/repository/cglib/jars/cglib-2.1.jar:/home/djb/maven/repository/dbunit/jars/dbunit-2.1.jar:/home/djb/maven/repository/dom4j/jars/dom4j-1.6.jar:/home/djb/maven/repository/ehcache/jars/ehcache-1.1.jar:/home/djb/maven/repository/gsbase/jars/gsbase-2.0.1.jar:/home/djb/maven/repository/hibernate/jars/hibernate-3.1-beta1.jar:/home/djb/maven/repository/hibernate/jars/hibernate-annotations-3.1-beta4.jar:/home/djb/maven/repository/hibernate/jars/hibernate-tools-3.0.0-alpha4.jar:/home/djb/maven/repository/jta/jars/jta-1.0.jar:/home/djb/maven/repository/jtidy/jars/jtidy-r8-21122004.jar:/usr/local/apps/inst/eclipse/eclipse-SDK-3.1-linux-gtk-x86_64/plugins/org.junit_3.8.1/junit.jar:/home/djb/maven/repository/log4j/jars/log4j-1.2.9.jar:/home/djb/maven/repository/mysql/jars/mysql-connector-java-3.1.7-bin.jar:/home/djb/maven/repository/velocity/jars/velocity-1.4.jar:/home/djb/maven/repository/velocity-tools/jars/velocity-tools-generic-1.1.jar:/home/djb/maven/repository/derby/jars/derby-10.0.2.1.jar:/home/djb/maven/repository/derby/jars/derbynet-10.0.2.1.jar:/home/djb/maven/repository/derby/jars/derbytools-10.0.2.1.jar:/home/djb/maven/repository/jtopen/jars/jtopen-jt400-4.8.jar:/home/djb/maven/repository/hsqldb/jars/hsqldb-1.7.3.3.jar:/home/djb/maven/repository/hibernate/jars/ejb-3.0-pr.jar:/usr/local/apps/inst/eclipse/eclipse-SDK-3.1-linux-gtk-x86_64/plugins/org.eclipse.jdt.junit_3.1.0/junitsupport.jar:/usr/local/apps/inst/eclipse/eclipse-SDK-3.1-linux-gtk-x86_64/plugins/org.eclipse.jdt.junit.runtime_3.1.0/junitruntime.jar, hibernate.show_sql=true, java.vm.specification.version=1.0, java.home=/usr/local/apps/inst/java/jdk1.5.0_04/jre, sun.arch.data.model=64, hibernate.connection.url=jdbc:derby:target/zpics;create=true, hibernate.dialect=org.hibernate.dialect.DerbyDialect, user.language=en, java.specification.vendor=Sun Microsystems Inc., hibernate.cglib.use_reflection_optimizer=true, java.vm.info=mixed mode, java.version=1.5.0_04, java.ext.dirs=/usr/local/apps/inst/java/jdk1.5.0_04/jre/lib/ext, sun.boot.class.path=/usr/local/apps/inst/java/jdk1.5.0_04/jre/lib/rt.jar:/usr/local/apps/inst/java/jdk1.5.0_04/jre/lib/i18n.jar:/usr/local/apps/inst/java/jdk1.5.0_04/jre/lib/sunrsasign.jar:/usr/local/apps/inst/java/jdk1.5.0_04/jre/lib/jsse.jar:/usr/local/apps/inst/java/jdk1.5.0_04/jre/lib/jce.jar:/usr/local/apps/inst/java/jdk1.5.0_04/jre/lib/charsets.jar:/usr/local/apps/inst/java/jdk1.5.0_04/jre/classes, java.vendor=Sun Microsystems Inc., file.separator=/, java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport.cgi, sun.io.unicode.encoding=UnicodeLittle, sun.cpu.endian=little, sun.desktop=gnome, sun.cpu.isalist=}
2005-08-08 18:08:09 [main] DEBUG com.dolby.pics.core.db.model.test.HibernateUtil [<clinit>() :52] - Configuration [/hibernate-test.cfg.xml] loaded
2005-08-08 18:08:10 [main] DEBUG com.dolby.pics.core.db.model.test.HibernateUtil [<clinit>() :54] - target exists: false
2005-08-08 18:08:12 [main] DEBUG org.hibernate.cfg.Configuration [buildSessionFactory() :1025] - Preparing to build session factory with filters : {}
2005-08-08 18:08:12 [main] DEBUG org.hibernate.cfg.AnnotationConfiguration [secondPassCompile() :180] - Executing first pass of annotated classes
Failed to invoke suite(): java.lang.ExceptionInInitializerError
java.lang.ExceptionInInitializerError
at com.dolby.pics.core.db.model.impl.BaseDAO.beginTransaction(BaseDAO.java:45)
at com.dolby.pics.core.db.model.impl.BaseDAO.<init>(BaseDAO.java:32)
at com.dolby.pics.core.db.model.impl.AbstractEntityObjectTestCase.<clinit>(AbstractEntityObjectTestCase.java:37)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
at junit.framework.TestSuite.createTest(TestSuite.java:131)
at junit.framework.TestSuite.addTestMethod(TestSuite.java:114)
at junit.framework.TestSuite.<init>(TestSuite.java:75)
at junit.framework.TestSuite.addTestSuite(TestSuite.java:101)
at com.dolby.pics.core.db.model.impl.AllTests.suite(AllTests.java:34)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.getTest(RemoteTestRunner.java:403)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:445)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: java.lang.NullPointerException
at org.hibernate.cfg.AnnotationBinder.buildInheritanceStates(AnnotationBinder.java:1711)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:184)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1026)
at com.dolby.pics.core.db.model.test.HibernateUtil.<clinit>(HibernateUtil.java:65)
... 20 more
Name and version of the database you are using: Apache Derby 10.0.2.1
The generated SQL (show_sql=true): Didn't get that far
Debug level Hibernate log excerpt: DEBUG
I'm having a problem with using a complex class heirachy with Hibernate. The classes are below. Each class is a subclass of the one above.
Code:
@EmbeddableSuperclass(access=AccessType.PROPERTY)
public abstract class EntityObject implements Serializable, IEntity
{
}
------------------------------------------------------------------------------
@EmbeddableSuperclass(access=AccessType.PROPERTY)
public abstract class EntityWithGeneratedId extends EntityObject
{
/**
*
*/
public static final String ATTR_ID = "id"; //$NON-NLS-1$
/** The unique id */
private String id;
/**
* Creates anew entity object
*/
public EntityWithGeneratedId()
{
super();
}
/**
* Gets the domain objects unqique identifier
* @return Returns the id.
*/
@Id(generate=GeneratorType.NONE)
@Column(name="ID", length=32, columnDefinition="char(32)") //$NON-NLS-1$ //$NON-NLS-2$
public String getId()
{
return this.id;
}
/**
* Sets this domain objects unique identifier
* @param id The id to set.
*/
void setId(final String id)
{
this.id = id;
}
}
------------------------------------------------------------------------------
@Entity(access = AccessType.PROPERTY)
@Table(name = "CUSTOM_FIELD")//$NON-NLS-1$
@Inheritance(strategy = InheritanceType.SINGLE_TABLE, discriminatorType=DiscriminatorType.STRING)
@DiscriminatorColumn(name = "CF_TYPE")//$NON-NLS-1$
public abstract class AbstractCFType extends EntityWithGeneratedId
{
---
}
------------------------------------------------------------------------------
@EmbeddableSuperclass (also tried without this)
public abstract class AbstractMultiFieldCFType extends AbstractCFType
{
---
}
------------------------------------------------------------------------------
@Entity
@Inheritance(discriminatorValue=CFType.CF_TYPE_MULTISELECT)
public class MultiSelectCFType extends AbstractMultiFieldCFType
{
private static final long serialVersionUID = -8510737279230143486L;
MultiSelectCFType()
{
super();
}
/**
* Creates a new category with the given name
* @param name The name for this category
* @param description The description of this custom field
*/
public MultiSelectCFType(String name, String description)
{
setName(name);
setDescription(description);
}
}
Whenever i try and run my test case i get the NullPointerException as detailed above. Am i getting the combination of @Entity and @EmbeddedSuperclass wrong? Or could it be that i have two abstract classes one after the other?
Any help would be greatfully appreciated.
Darren.