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: HQL en Criteria Besoin d aire
PostPosted: Thu Aug 24, 2006 10:09 am 
Newbie

Joined: Wed Aug 23, 2006 9:52 am
Posts: 2
Bonjour quelqu'un a t il une idée pour traduire cette requete HQL en Criteria ??

Merci d'avance ...

Les Objets en jeu sont :

Ressource
GroupeRessource
TypeVinotech
RessourceTypeVinotech

Code:

String queryString =
   "select gr.Idmembre "
+ "from GroupeRessource gr "
+ "join gr.Idmembre Ressource "
+ "join Ressource.TYPE_VINOTECHList RessourceTypeVinotech "
+ "join RessourceTypeVinotech.IdtypeVinotech TypeVinotech "
+ "where TypeVinotech.IdtypeVinotech = :_tvId "
+ "and gr.Idgroupe.Idressource = :_gId";

IQuery query = session.CreateQuery(queryString);
query.SetString("_tvId", _tvId.ToString());
query.SetString("_gId", _gId.ToString());
ressource = query.List();



http://www.art-touch.com?u=aurelien


    Top
     Profile  
     
     Post subject:
    PostPosted: Thu Aug 24, 2006 3:35 pm 
    Regular
    Regular

    Joined: Fri Aug 18, 2006 2:40 pm
    Posts: 51
    Location: Metz, France
    Un truc comme ca:

    Code:
    Criteria c  = session.createCriteria(GroupeRessources.class)
    c.createAlias("Idmembre.TYPE_VINOTECHLis.IdtypeVinotech","TypeVinotech")
    c.add(Restrictions.eq("TypeVinotech.IdtypeVinotech", tvId)
    c.createAlias("Idgroupe","idgrp")
    c.add(Restrictions.eq("idgrp.", tvId)
    c.setProjection(Projections.property("Idmembre"))

    List resultats = c.list();


    Mais il y a surement quelques erreurs, il faut créer un alias pour chaque join qui rentre dans la where clause.

    _________________
    Denis
    Don't forget to rate ... thanks.


    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.