-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: strange property type detenction when type for generics type
PostPosted: Tue Jan 24, 2006 9:58 am 
Newbie

Joined: Tue Dec 27, 2005 8:24 am
Posts: 2
Hello, i have a problem when using generics type parameters for entity properties.
when i have a
@Entity
class X<E> {
@Basic
E getValue();
}
hibernate tries to somehow discover the actual type for the parameter.
It didn't work this way in hib-anno 3.1beta6 and does not work this way for mapped fields.
is this behavior (apart the nullpointer) correct? and is the below mentioned mapping correct?


Hibernate version:
hibernate 3.1.1
hibernate-annotations 3.1beta8
hibernate-entitymanager 3.1beta6

Mapping documents:
@Entity
@Inheritance (strategy = InheritanceType.SINGLE_TABLE)
@SequenceGenerator (name = "Generator", sequenceName = "hibernate_seq")
public abstract class TestTopClass<Test extends TestHelpClass> {
private long id;
private Test test;

@Id
@GeneratedValue (generator = "Generator", strategy = GenerationType.AUTO)
public long getId() {
return id;
}

public void setId(long id) {
this.id = id;
}

@OneToOne
public Test getTest() {
return test;
}

public void setTest(Test test) {
this.test = test;
}
}

@Entity
public class TestMiddleClass extends TestTopClass<TestHelpClass> {

}

@Entity
public class TestHelpClass {
@Id
private long id;
}

Full stack trace of any exception that occurs:
java.lang.NullPointerException
at org.hibernate.cfg.PropertyInferredData.extractType(PropertyInferredData.java:212)
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.buildMappings(Configuration.java:996)
at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:722)
at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:161)
at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:567)
at org.hibernate.ejb.Ejb3Configuration.createContainerEntityManagerFactory(Ejb3Configuration.java:245)
at cz.eurotel.persistencehibernate.ResourceBasedSessionManager.initializeResource(ResourceBasedSessionManager.java:74)

Debug level Hibernate log excerpt:
TEST 2006-01-24T13:01:03.171 INFO [TestTask] org.hibernate.ejb.Ejb3Configuration - found EJB3 Entity bean: test.persistence.hibernate.TestHelpClass
TEST 2006-01-24T13:01:03.171 INFO [TestTask] org.hibernate.ejb.Ejb3Configuration - found EJB3 Entity bean: test.persistence.hibernate.TestMiddleClass
TEST 2006-01-24T13:01:03.187 INFO [TestTask] org.hibernate.ejb.Ejb3Configuration - found EJB3 Entity bean: test.persistence.hibernate.TestTopClass
TEST 2006-01-24T13:01:03.421 DEBUG [TestTask] org.hibernate.cfg.AnnotationConfiguration - Execute first pass mapping processing
TEST 2006-01-24T13:01:03.421 DEBUG [TestTask] org.hibernate.cfg.AnnotationConfiguration - Process hbm files
TEST 2006-01-24T13:01:03.421 DEBUG [TestTask] org.hibernate.cfg.AnnotationConfiguration - Process annotated classes
TEST 2006-01-24T13:01:03.515 INFO [TestTask] org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: test.persistence.hibernate.TestHelpClass
TEST 2006-01-24T13:01:03.546 DEBUG [TestTask] org.hibernate.cfg.Ejb3Column - Binding column TYPE unique false
TEST 2006-01-24T13:01:03.593 DEBUG [TestTask] org.hibernate.cfg.annotations.EntityBinder - Import with entity name=TestHelpClass
TEST 2006-01-24T13:01:03.609 INFO [TestTask] org.hibernate.cfg.annotations.EntityBinder - Bind entity test.persistence.hibernate.TestHelpClass on table TestHelpClass
TEST 2006-01-24T13:01:07.406 DEBUG [TestTask] org.hibernate.cfg.AnnotationBinder - Processing test.persistence.hibernate.TestHelpClass per property annotation
TEST 2006-01-24T13:01:07.406 DEBUG [TestTask] org.hibernate.cfg.AnnotationBinder - Processing test.persistence.hibernate.TestHelpClass per field annotation
TEST 2006-01-24T13:01:09.046 DEBUG [TestTask] org.hibernate.cfg.AnnotationBinder - Processing annotations of test.persistence.hibernate.TestHelpClass.id
TEST 2006-01-24T13:01:09.062 DEBUG [TestTask] org.hibernate.cfg.Ejb3Column - Binding column id unique false
TEST 2006-01-24T13:01:09.062 DEBUG [TestTask] org.hibernate.cfg.AnnotationBinder - id is an id
TEST 2006-01-24T13:01:09.062 DEBUG [TestTask] org.hibernate.cfg.annotations.SimpleValueBinder - building SimpleValue for id
TEST 2006-01-24T13:01:09.078 DEBUG [TestTask] org.hibernate.cfg.annotations.PropertyBinder - Building property id
TEST 2006-01-24T13:01:09.078 DEBUG [TestTask] org.hibernate.cfg.annotations.PropertyBinder - Cascading id with null
TEST 2006-01-24T13:01:09.078 DEBUG [TestTask] org.hibernate.cfg.AnnotationBinder - Bind @Id on id
TEST 2006-01-24T13:01:09.093 DEBUG [TestTask] org.hibernate.validator.ClassValidator - ResourceBundle ValidatorMessages not found. Delegate to org.hibernate.validator.resources.DefaultValida
torMessages
TEST 2006-01-24T13:01:09.093 INFO [TestTask] org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: test.persistence.hibernate.TestTopClass
TEST 2006-01-24T13:01:09.093 DEBUG [TestTask] org.hibernate.cfg.Ejb3Column - Binding column TYPE unique false
TEST 2006-01-24T13:01:09.093 DEBUG [TestTask] org.hibernate.cfg.annotations.EntityBinder - Import with entity name=TestTopClass
TEST 2006-01-24T13:01:09.093 INFO [TestTask] org.hibernate.cfg.annotations.EntityBinder - Bind entity test.persistence.hibernate.TestTopClass on table TestTopClass
TEST 2006-01-24T13:01:09.093 DEBUG [TestTask] org.hibernate.cfg.AnnotationBinder - Setting discriminator for entity test.persistence.hibernate.TestTopClass
TEST 2006-01-24T13:01:09.109 DEBUG [TestTask] org.hibernate.cfg.AnnotationBinder - Add sequence generator with name: Generator
TEST 2006-01-24T13:01:11.406 DEBUG [TestTask] org.hibernate.cfg.AnnotationBinder - Processing test.persistence.hibernate.TestTopClass per property annotation
TEST 2006-01-24T13:03:49.656 DEBUG [TestTask] sw.objects.TestTask - test HibernateTest crashed
java.lang.NullPointerException
at org.hibernate.cfg.PropertyInferredData.extractType(PropertyInferredData.java:212)
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.buildMappings(Configuration.java:996)
at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:722)
at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:161)
at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:567)
at org.hibernate.ejb.Ejb3Configuration.createContainerEntityManagerFactory(Ejb3Configuration.java:245)
at cz.eurotel.persistencehibernate.ResourceBasedSessionManager.initializeResource(ResourceBasedSessionManager.java:74)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 25, 2006 2:47 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Open a case on that, but I don't think it makes sense in ORM to map such a structure. We might want to avoid issue if targetEntity is explicitly defined though

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 14, 2006 11:57 am 
Newbie

Joined: Thu Apr 15, 2004 4:31 pm
Posts: 7
Was there an issue opened for this at all?


Top
 Profile  
 
 Post subject: The bug report
PostPosted: Thu Mar 02, 2006 4:49 am 
Newbie

Joined: Thu Mar 02, 2006 4:39 am
Posts: 3
I have the same problem, and found an Issue at http://opensource2.atlassian.com/projec ... se/ANN-181 .


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.