-->
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.  [ 3 posts ] 
Author Message
 Post subject: @MapKeyManyToMany and value column name
PostPosted: Tue May 22, 2007 8:24 am 
Newbie

Joined: Tue May 22, 2007 6:59 am
Posts: 2
Hibernate version:
3.2.1, hibernate-annotations 3.3.0.ga

I'm using a Map<Entity, OtherEntity> property in an Entity. The annotation I'm using is the following:

@CollectionOfElements(fetch = FetchType.EAGER)
@MapKeyManyToMany(joinColumns = {@JoinColumn(name = "ID_ACCT", nullable = true) })
@JoinTable(name = "PROFILE_DETAIL", joinColumns = {@JoinColumn(name = "ID_COMM_TRANS") })
@Fetch(FetchMode.SUBSELECT)
@Column(name = "ID_CURVE")
private Map<Account, Curve> profileDetails;

The table PROFILE_DETAIL table is defined as:

PROFILE_DETAIL:
ID_PROFILE_DETAIL,
ID_ACCT, <- map key
ID_CURVE, <- map value
ID_COMM_TRANS

The problem is with the id_curve column, since the query done by hibernate is:

select profiledet0_.ID_COMM_TRANS as ID1_1_, profiledet0_.profileDetails_ID_CURVE as p ...

The column used by hibernate is "profileDetails_ID_CURVE" and not "ID_CURVE". Why hibernate adds the java property name to the column name? If I set the column name as the one used by hibernate, the mapping works fine, but I would like to avoid this kind of dependency.

Am I misusing the @MapKeyManyToMany/@Column annotations?

Cheers,
Filippo


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 22, 2007 6:49 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
replace @CollectionOfEmelents by @ManyToMany (I think that's what you want)
and the column name is defined by @JoinTable(inverseJoinColumn=...)

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 23, 2007 4:32 am 
Newbie

Joined: Tue May 22, 2007 6:59 am
Posts: 2
emmanuel wrote:
replace @CollectionOfEmelents by @ManyToMany (I think that's what you want)
and the column name is defined by @JoinTable(inverseJoinColumn=...)


Thanks alot, you're suggestion was right.

Cheers,
Filippo


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