-->
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: ManyToMany Associations and Maps
PostPosted: Wed Jul 12, 2006 6:27 pm 
Newbie

Joined: Sat Sep 03, 2005 1:04 pm
Posts: 12
I have a ManyToMany Association, and on one side I'd like to collect related elements by a Map... but I have same problems declaring the map key (it should be simple the identifier of the collected entity):

Following the java.persistence specification I should write samething like:

@ManyToMany(
targetEntity=Target.class
)
@MapKey(
name="id"
)
@JoinTable(
name="ASSOCIATION_TABLE",
joinColumns={@JoinColumn(name="owner_id")},
inverseJoinColumns={@JoinColumn(name="tagret_id")}
)
public Map getMapOfTarget() {
return ..
}

But this seams not to work with hibernate... there's same SQL grammar errors in the generated sql

Then I try by the hibernate secifics annotations org.hibernate.annotations.MapKey and org.hibernate.annotations.MapKeyManyToMany but I can't understand how they work... I tried puting the name of join colum of ASSOCIATION TABLE or id colum of terget TABLE but I allways get a ...

Caused by: java.lang.NullPointerException
at org.hibernate.cfg.annotations.MapBinder.bindKeyFromAssociationTable(MapBinder.java:109)
at org.hibernate.cfg.annotations.MapBinder.access$000(MapBinder.java:55)
at org.hibernate.cfg.annotations.MapBinder$1.secondPass(MapBinder.java:78)
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 it.prainf.utils.hibernate.HibernateUtil.<clinit>(HibernateUtil.java:43)
... 126 more

Sameone has same idea?

TY


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.