-->
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: using MapKey when target property name is not column name
PostPosted: Thu Feb 02, 2006 12:24 pm 
Newbie

Joined: Thu Feb 02, 2006 12:02 pm
Posts: 2
Location: Belgium
Hello,
I'm trying to map an existing schema with entity beans and I have some troubles with the MapKey annotation due to column not having same name as property.

Map in owning class:
Code:
  @OneToMany(cascade=CascadeType.ALL)
  @JoinColumn(name="`cardId`")
  @MapKey(name="subProdType")
  public Map<String, CardState> getStates() {
    return states;
  }


Class thats ends up in the map:
Code:
public class CardState {
   private String subProdType;
   ...
   @Column(name="`subProdType`")
   public String getSubProdType() {
     return subProdType;
   }
   public void setSubProdType(String subProdType) {
      this.subProdType = subProdType;
   }
   ...


When trying to get the state, the generated query looks for a column named after the property name which doesn't work since the column has case sensitive name:


select states0_."cardId" as cardId8_1_,
states0_."stateId" as stateId1_1_,
states0_.subProdType as formula15_1_,
states0_."stateId" as stateId1_198_0_,
states0_."state" as state2_198_0_,
states0_."subProdType" as subProdT3_198_0_,
...
from "cardState" states0_
where states0_."cardId"=?


Any idea how I could bypass this little annoyance?
I know alternatives to usage of maps exist but cascading and automatic loading is very convenient here.
I was also curious about why stateId appears twice in the query as it doesn't when loading a CardState entity directly.
Thanks for your help,

Eric.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 08, 2006 1:46 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Open a JIRA issue, I will need to check the column.isQuote() somewhere

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 09, 2006 5:39 am 
Newbie

Joined: Thu Feb 02, 2006 12:02 pm
Posts: 2
Location: Belgium
Done.
http://opensource2.atlassian.com/projec ... se/ANN-243


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.