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: Mapping Set collection within Map
PostPosted: Wed Apr 21, 2010 11:43 pm 
Beginner
Beginner

Joined: Fri Jun 23, 2006 6:40 pm
Posts: 25
Dear Members

I have the table Product and I need work with Map<k,Set<Item>> x variable for such class, in the Set collection Item is a class/table where each row inserted can be of many types like

Alfa(alfa1 ... alfaN)
  • alfa1
  • alfa2
  • alfa3
  • alfa4
  • ...
  • alfaN


Beta(beta1 ... betaN )
  • beta1
  • beta2
  • beta3
  • beta4

Delta (delta1 ... deltaN)
  • delta1
  • delta2
  • delta3
  • delta4

Then a Product is created for many Item's (alfa,beta,delta), imagine like ingredients to cook a cake

The point is that each Set<Item> collection (alfa,beta,delta) creates a Product therefore think

product1 has
  1. alfa1
  2. alfa2
  1. beta1
  2. beta2
  3. beta3
  1. delta1
  2. delta2
  3. delta3
  4. delta4

The point would be has the follow

x.put("alfa", Set<Item> of type alfa 1..2)
x.put("beta", Set<Item> of type beta 1..3)
x.put("delta",Set<Item> of type delta 1..4)

therefore how I could do this mapping to persistence the Set within the Hash collection?
I work with annotations, how should be the XML generated?

Thanks in advanced

_________________
kill your pride, share your knowledge with all


Top
 Profile  
 
 Post subject: Re: Mapping Set collection within Map
PostPosted: Thu Apr 22, 2010 10:57 am 
Newbie

Joined: Mon Apr 06, 2009 9:55 pm
Posts: 12
Hi Dr Pompeii,

Have a look at the blog:

http://blog.xebia.com/2007/10/05/mappin ... hibernate/

In this blog a map of lists is used. I belive you can use sets (have a look at http://commons.apache.org/collections/a ... ueMap.html there you can specify which type of collection you want to use).

Unfortunately I could not find how to annotate collection with UserCollectionType as it is not supported in hibernate annotations. But it can be set programmatically at a configuration stage.

Hope it helps.
Anton


Top
 Profile  
 
 Post subject: Re: Mapping Set collection within Map
PostPosted: Fri Apr 23, 2010 5:06 pm 
Beginner
Beginner

Joined: Fri Jun 23, 2006 6:40 pm
Posts: 25
Hello aantoxa

Thanks for the reply, interesting link, but such code has a problem
1) something complicated
2) depends with MultiValueMap where has a note its API
Note that MultiValueMap is not synchronized and is not thread-safe
I need this for many users in real time

Anyway I found a solution with a re design

My Best Regards!!!

-Manuel

_________________
kill your pride, share your knowledge with all


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.