| Hi,
 I am using hibernate version 3.2.0.CR2 and trying to map classes through Annotations(version 3.2.0.CR1).
 I have got the following classes and am trying to refer to some other entity through one of the elements in composite primary key.
 
 
 @Entity
 @Table(name="B_level")
 @AssociationOverride(
 name="AEntityPk.B",
 joinColumns=@JoinColumn(name="B_id", referencedColumnName="id")
 // one of primary key elements referring to some other entity with column name "B_id"
 )
 public class AEntity implements Serializable {
 ...
 private AEntityPk AEntityPk; // composite primary key
 ...
 }
 
 @Embeddable
 public class AEntityPk implements Serializable {
 ...
 private BEntity B;
 ...
 }
 
 @Entity
 @Table(
 name="B",
 uniqueConstraints={@UniqueConstraint(columnNames={"id", "c"})}
 )
 public class BEntity implements Serializable {
 
 @OneToMany(mappedBy="AEntityPk.B")
 // This is an erroneous mapping. Suggest the right one!!
 public Set<AEntity> getAs() {
 return As;
 }
 public void setAs(Set<AEntity> As) {
 this.As = As;
 }
 }
 
 
 I am able to retrieve unidirectional ManyToOne mapping but when i am trying to make this mapping work as bidirectional OneToMany i am getting a MappingException. Following is the stackTrace for the exception.
 
 
 org.hibernate.AnnotationException: mappedBy reference an unknown property: com.drishti.dacx.server.cc.configuration.hierarchy.AEntity.AEntityPk.B in com.drishti.dacx.server.cc.configuration.hierarchy.BEntity.AEntityPk.B
 at org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.java:503)
 at org.hibernate.cfg.annotations.CollectionBinder$1.secondPass(CollectionBinder.java:468)
 at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:35)
 at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1049)
 at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:302)
 at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1205)
 at com.drishti.dacx.core.configuration.impl.ConfigurationManager.startComponent(ConfigurationManager.java:152)
 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)
 
 
 I am using Postgresql 8.0 as the database server.
 Kindly make me figure out the mapping exception and also try suggesting database optimizations, if required by this mapping.
 
 Thanks.
 _________________
 Regards,
 Gautam
 
 
 |