Hibernate version: 3.1.2
Mapping documents: Annotations 3.1b8
Code between sessionFactory.openSession() and session.close(): We don't get that far.
Full stack trace of any exception that occurs: Story first...
Suppose you define a base class for all Hibernate-persisted classes:
/**
* @param <I> The type (class) to be used for the ID field.
* @param <V> The type (class) to be used for the Version field.
*/
@MappedSuperclass
public abstract class HibernateBase<I, V> implements Serializable {
protected I id = null;
protected V version = null;
<<accessors omitted>>
}
Now suppose you further extend that with another base class for Hibernate-persisted classes that use typed Property objects:
/***
* @param <I> The type (class) to be used for the ID field.
* @param <V> The type (class) to be used for the Version field.
* @param <P> The type (class) to be used for the Properties, which must extend PropertyBase.
*/
@MappedSuperclass
public abstract class PropertiesBase<I, V, P extends PropertyBase> extends HibernateBase<I, V> {
<<omitted...>>
}
Next in your inheritance tree you provide a class that defines all three generics listed so far:
@MappedSuperclass
public abstract class TaskBase extends PropertiesBase<Integer, Integer, TaskProperty> {
<<omitted...>>
}
And finally, a domain-specific implementation class to actually be used:
@Entity
@Table(name = "te_task")
public class CMEJTask extends TaskBase {
<<omitted...>>
}
When you try to start this code, you will get the error listed below. Note that this worked just fine when the middle class, PropertiesBase, defined the generic classes. It wasn't until I pushed them down one level further, to the TaskBase, that I received the Hibernate assertion failure. Java lets me "carry" my generics through multiple levels of inheritance, so I'm wondering if this might not be a Hibernate bug.
781 [main] DEBUG org.hibernate.cfg.annotations.EntityBinder - Import with entity name=CMEJTask
821 [main] INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity com.infor.dist.te.sxe.model.CMEJTask on table te_task
821 [main] DEBUG org.hibernate.cfg.AnnotationBinder - Processing com.infor.dist.te.sxe.model.CMEJTask per property annotation
841 [main] ERROR org.hibernate.AssertionFailure - an assertion failure occured (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session)
org.hibernate.AssertionFailure: Unable to extract type of property id: I
at org.hibernate.cfg.PropertyInferredData.extractType(PropertyInferredData.java:236)
at org.hibernate.cfg.PropertyInferredData.execute(PropertyInferredData.java:124)
at org.hibernate.cfg.PropertyInferredData.skip(PropertyInferredData.java:60)
at org.hibernate.cfg.AnnotationBinder.addAnnotatedElement(AnnotationBinder.java:900)
at org.hibernate.cfg.AnnotationBinder.addElementsOfAClass(AnnotationBinder.java:868)
at org.hibernate.cfg.AnnotationBinder.getElementsToProcess(AnnotationBinder.java:717)
at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:547)
at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:276)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:210)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1168)
|