-->
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.  [ 2 posts ] 
Author Message
 Post subject: Embedded unidirectional OneToMany causes MappingException
PostPosted: Mon Nov 06, 2006 5:43 am 
Newbie

Joined: Fri Jun 11, 2004 8:25 am
Posts: 1
Hibernate version:
3.2.0 GA (Annotations 3.2.0 GA, Entitymanager 3.2.0 GA)

Mapping documents:
Code:
@javax.persistence.Entity
public class Entity {
    @Id
    @GeneratedValue
    private Integer id;
    private String key;
    private EmbeddedObject embedded;

    ... getters/setters ...
}

@Embeddable
public class EmbeddedObject {
    @OneToMany
    @JoinColumn(name = "entity_key", referencedColumnName = "key")   
    private List<AnotherEntity> list;

    ... getter/setter ...
}

@Entity
public class AnotherEntity {
    @Id
    @GeneratedValue
    private Integer id;
   
    @Column(name = "entity_key")
    private String key;

    ... getters/setters ...
}



Full stack trace of any exception that occurs:
Code:
10:11:46 DEBUG [EntityBinder][bindEntity:212] Import with entity name=AnotherEntity
10:11:46 INFO [EntityBinder][bindTable:340] Bind entity test.AnotherEntity on table AnotherEntity
10:11:46 DEBUG [AnnotationBinder][addElementsOfAClass:940] Processing test.AnotherEntity property annotation
10:11:46 DEBUG [AnnotationBinder][addElementsOfAClass:940] Processing test.AnotherEntity field annotation
org.hibernate.MappingException: property not found: _test_AnotherEntity_embedded.listin entity: test.Entity
   at org.hibernate.mapping.PersistentClass.getRecursiveProperty(PersistentClass.java:337)
   at org.hibernate.cfg.annotations.CollectionBinder.buildCollectionKey(CollectionBinder.java:930)
   at org.hibernate.cfg.annotations.CollectionBinder.bindCollectionSecondPass(CollectionBinder.java:1215)
   at org.hibernate.cfg.annotations.CollectionBinder.bindOneToManySecondPass(CollectionBinder.java:585)
   at org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.java:517)
   at org.hibernate.cfg.annotations.CollectionBinder$1.secondPass(CollectionBinder.java:471)
   at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:43)
   at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1054)
   at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:296)
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1210)
   at test.TestCase.buildSessionFactory(TestCase.java:48)
   at test.TestCase.setUp(TestCase.java:58)
   at junit.framework.TestCase.runBare(TestCase.java:125)
   at junit.framework.TestResult$1.protect(TestResult.java:106)
   at junit.framework.TestResult.runProtected(TestResult.java:124)
   at junit.framework.TestResult.run(TestResult.java:109)
   at junit.framework.TestCase.run(TestCase.java:118)
   at junit.framework.TestSuite.runTest(TestSuite.java:208)
   at junit.framework.TestSuite.run(TestSuite.java:203)
   at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128)
   at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: org.hibernate.MappingException: property not found: _test_AnotherEntity_embedded.listin entity: test.Entity
   at org.hibernate.mapping.PersistentClass.getRecursiveProperty(PersistentClass.java:368)
   at org.hibernate.mapping.PersistentClass.getRecursiveProperty(PersistentClass.java:334)
   ... 24 more
Caused by: org.hibernate.MappingException: property not found: _test_AnotherEntity_embedded on entity test.Entity
   at org.hibernate.mapping.PersistentClass.getProperty(PersistentClass.java:384)
   at org.hibernate.mapping.PersistentClass.getRecursiveProperty(PersistentClass.java:358)
   ... 25 more
10:11:46 DEBUG [AnnotationBinder][processElementAnnotations:1032] Processing annotations of test.AnotherEntity.id
10:11:46 DEBUG [Ejb3Column][bind:161] Binding column id unique false
10:11:46 DEBUG [AnnotationBinder][processElementAnnotations:1153] id is an id
10:11:46 DEBUG [SimpleValueBinder][make:220] building SimpleValue for id
10:11:46 DEBUG [PropertyBinder][make:122] Building property id
10:11:46 DEBUG [PropertyBinder][make:155] Cascading id with null
10:11:46 DEBUG [AnnotationBinder][processElementAnnotations:1186] Bind @Id on id
10:11:46 DEBUG [AnnotationBinder][processElementAnnotations:1032] Processing annotations of test.AnotherEntity.key
10:11:46 DEBUG [Ejb3Column][bind:161] Binding column entity_key unique false
10:11:46 DEBUG [PropertyBinder][bind:102] binding property key with lazy=false
10:11:46 DEBUG [SimpleValueBinder][make:220] building SimpleValue for key
10:11:46 DEBUG [PropertyBinder][make:122] Building property key
10:11:46 DEBUG [PropertyBinder][make:155] Cascading key with null
10:11:46 DEBUG [AnnotationConfiguration][processFkSecondPassInOrder:329] processing manytoone fk mappings
10:11:46 DEBUG [Configuration][secondPassCompile:1044] processing extends queue
10:11:46 DEBUG [Configuration][secondPassCompile:1048] processing collection mappings
10:11:46 DEBUG [CollectionSecondPass][doSecondPass:41] Second pass for collection: test.Entity.embedded.list
10:11:46 DEBUG [CollectionBinder][bindOneToManySecondPass:551] Binding a OneToMany: test.EmbeddedObject.list through a foreign key
10:11:46 INFO [CollectionBinder][bindOneToManySecondPass:581] Mapping collection: test.Entity.embedded.list -> AnotherEntity


Test case
EmbeddedUnidirectionalOneToMany.zip

I've tried to map a unidirectional OneToMany in an embedded object, without success. A bidirectional is no problem, but when using referencedColumnName on @JoinColumn in an @Embeddable something odd happens as you can see in the above stacktrace. I've provided a test case showing the error and my question is: Have I messed up or is this not yet implemented?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 07, 2006 8:00 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
this is not supported by hibernate core either I think

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.