-->
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.  [ 1 post ] 
Author Message
 Post subject: Bidirectional mapping of an element in composite primary key
PostPosted: Mon Sep 04, 2006 8:42 am 
Newbie

Joined: Mon Sep 04, 2006 7:07 am
Posts: 2
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


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

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.