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 ?