-->
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: Requêtes avec critères sur un attribut de type MAP
PostPosted: Mon Nov 28, 2005 8:47 pm 
Beginner
Beginner

Joined: Mon Nov 28, 2005 7:16 pm
Posts: 20
Bonjour,

J'ai une classe comme ceci :

Code:
class Person{
  long id;
  Map<String,String> attributs;
}


mappée comme voici :

Code:
<hibernate-mapping>
    <class name="Person" table="PERSON">
        <id name="id" column="PERSON_ID">
            <generator class="increment"/>
        </id>
       
        <map name="attributs" table="PERSON_ATT"">
             <key column="PERSON_ID"/>
             <map-key column="MAP_KEY" type="string"/>
           <element column="MAP_VAL" type="string"/>
       </map>
    </class>
</hibernate-mapping>


Ce que je souhaite faire c'est récupérer toute les "PERSON" possédant la clé "Nom" avec la valeur "une_valeur_critere" dans leurs attributs.

1) Je peux le faire avec un requete SQL du style :

Code:
select * from person inner join person_att where person_att.map_key = 'Nom' and person_att.map_val = 'une_valeur_critere'


2) Comment le faire avec du HQL ?

3) Existe t'il une méthode avec les "Criteria" ?

Sachant qu'a terme j'aimerais faire une méthode qui prend en parametre une "MAP" de critères et qui retourne la liste des personnes répondant a ces critères.

Sinon j'ai aussi pensé faire :

4)

Code:
class Person{
  long id;
  Set<PersonAtt> attributs;
}

class PersonAtt{
int id;
string val;
}


et ainsi pouvoir peut être utiliser les "criteria" plus simplement...
Ce qui m'embete avec solution c'est d'avoir une classe "pour rien".

Je débute avec hibernate et j'aimerais faire au mieux donc j'en appel a vos conseils avisés :)

Merci d'avance.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 29, 2005 1:55 pm 
Beginner
Beginner

Joined: Mon Nov 28, 2005 7:16 pm
Posts: 20
Bon apparement je suis pas le seul a avoir le problème :)

http://forum.hibernate.org/viewtopic.php?t=932908
http://forum.hibernate.org/viewtopic.php?t=943792
http://forum.hibernate.org/viewtopic.php?t=946236


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