-->
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: Possible to join fetch the keys of a MapKeyManyToMany?
PostPosted: Thu Jun 05, 2008 10:30 pm 
Newbie

Joined: Mon Nov 13, 2006 4:45 pm
Posts: 5
Is it possible to specify in HQL that the key objects of a MapKeyManyToMany are eagerly join fetched?

HQL:
select myClass
from MyClass as myClass
left join fetch myClass.attribValues

This HQL statement will eagery join fetch the map values, but not the map keys.

@Entity
public class MyClass {

@ManyToMany
@MapKeyManyToMany(joinColumns = @JoinColumn(name = "attribId"))
@JoinTable(name = "AttribValue", joinColumns = @JoinColumn(name = "myClassId"), inverseJoinColumns = @JoinColumn(name = "attribValueId"))
private Map<Attrib, AttribValue> attribValues;

}


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 20, 2008 6:25 am 
Newbie

Joined: Mon Nov 15, 2004 1:52 pm
Posts: 7
As a reference for people having the same question and finding this thread unanswered as I did :

I went a little bit farther, using the "index" pseudo-property on the map :
left join fetch myClass.attribValues attribValues
join fetch attribValues.index

(I had to alias the map)

The generated SQL looks good, with an inner join on the key, but there is an issue when filling the map, so that it will have at most 1 entry, even if there are several keys in persistence : http://forum.hibernate.org/viewtopic.php?t=992438


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.