-->
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: Suggestions for MAP Mapping...
PostPosted: Wed Feb 04, 2009 11:27 am 
Newbie

Joined: Wed Feb 04, 2009 8:30 am
Posts: 2
Hi all,

I have been struggling with this issue in the last 2 days. I read documentation and around but I still cannot find a suitable solution.

I have a class Item that contains a map<String, Group> where Group contains the localized name for a specific language code of the group which Item belongs.

Code:
public class Item {
private Map<String,Group> groups = new HashMap<String,Group>();
private String name;
// getter and setter
}

public class Group {
private String name;

// getter and setter
}


The tables are:
Code:
items:
id -> int primary key
name -> String
fk_groupID -> This is the key to the groupsTable

groups:
id -> int primary key
groupID -> this should be pointed by the fk_groupID column
code -> 2 letter language code [en,de.. and so on]
name  - the localized name for the specific language code


my plan is to retrieve for an item the localized group name for an item by issuing something like:
Item.getGroup().get("EN").getName()

I tried to add to the map of the Item mapping::
Code:
<map name="group" table="groups">
  <key column="groupID" />
  <map-key type="string" column="code" />
  <composite-element class="Group">
    <property name="name" column="name" />
  </composite-element>
</map>


This way is not working and the groupID in the table Groups is becoming the fk for Items, which is not correct.

Can anyone give me some tips on this ?

_________________
--

Davide


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 18, 2009 7:59 am 
Newbie

Joined: Wed Feb 04, 2009 8:30 am
Posts: 2
So far I resolved partially using the HQL query string and the processing the returing data and reorganizing them.

I believe that maybe there is a way to use straight the mapping for this avoiding the my processing.

I will keep you updated so in case anyone faces the same problem will have a working solution...

_________________
--

Davide


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.