-->
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.  [ 4 posts ] 
Author Message
 Post subject: Mapping a map with string array
PostPosted: Wed Nov 07, 2007 12:09 pm 
Newbie

Joined: Thu Nov 30, 2006 10:06 am
Posts: 9
Hello all! Can anybody suggest how to map such construct:

Code:
Map<String,String[]>


There should be an <array> element inside <map>, but i can't get where to put it...


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 07, 2007 12:35 pm 
Beginner
Beginner

Joined: Tue Jun 26, 2007 2:31 pm
Posts: 21
please explain the scenario where you need to do it clearly


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 07, 2007 12:39 pm 
Newbie

Joined: Thu Nov 30, 2006 10:06 am
Posts: 9
I need to persist user preferences in DB. The main class is User and I need preferences to have multiple values for one key.

Code:
class User {
     private long userId;
     private Map<String, String[]> preferences;
}


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 08, 2007 8:19 am 
Newbie

Joined: Thu Nov 30, 2006 10:06 am
Posts: 9
Maybe a better approach is to map

Code:
Map<String, UserPreference>


with mapping

Code:

<class name="test.User" table="User">
...
<map name="preferences" table="USER_PR" >
       <key column="USER_ID"/>
       <index column="PR_KEY" type="string"/>
       <many-to-many class="test.UserPreference" column="PR_ID"  />
</map>

</class>



where UserPreference is defined

Code:
class UserPreference {
       Long id;
       List<String> values;
}


Any suggestions?


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