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.  [ 1 post ] 
Author Message
 Post subject: Mapping de collection dans une Map<String, List<Contac
PostPosted: Thu Nov 23, 2006 12:49 pm 
Newbie

Joined: Thu Nov 23, 2006 12:18 pm
Posts: 7
Je me heurte à un problème de mapping et j'aimerais savoir si il y a une solution.
Donc à l'origine j'avais :
Des User avec une liste de Contact dans une relation one-to-many. Les contacts ont tous un type.
CE qui me permettait donc avec le mapping suivant :
Code:
<class name="User" ...>
...
<map name="contacts" table="CONTACT" lazy="false" cascade="all,delete-orphan" inverse="true" >
  <key column="SPC_SPR_ID" not-null="true" />
  <map-key column="SPC_SCT_CODE" type="string" />
  <one-to-many class="com.nexo.susan.be.model.Contact" />
</map>
...
</class>


Ce qui me donnait un très beau :
Map<String, Contact> user.getContacts() pour obtenir la liste des contacts d'un User indexée par contact type.

Or, dernièrement il a été décidé de pouvoir associer plusieurs contacts du même type à un utilisateur, donc changement du modèle coté clé primaire, etc...
Sauf que maintenant j'aimerais obtenir une :
Map<String, List<Contact>> user.getContacts() qui pour un User me donne la liste des Contact d'un même type, le tout indéxé par ce type.

Est-ce possible à faire en mapping de collection où dois-je forcément utiliser du HQL et indexer le tout a la mimine ?

Merci d'avance
Christophe.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.