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: Comment sélectionner une partie de la grappe ?
PostPosted: Fri Feb 23, 2007 11:11 am 
Newbie

Joined: Tue Feb 13, 2007 11:48 am
Posts: 1
Bonjour,
Mon problème est le suivant :
J'ai un objet principal (un profile) qui est en relation many_to_many avec 3 autres objets (ci dessous mapping)

<hibernate-mapping package="domain">
<class name="Profile" table="PROFILE" >

<id column="idProfile" name="id">
<generator class="increment"/>
</id>
<array name="prestations" table="PROFILE_PRESTATION" cascade="merge, save-update">
<key column="idProfile"/>
<index column="position"/>
<many-to-many column="idPrestation"
class="Prestation"/>
</array>
<array name="segments" table="PROFILE_SEGMENT" cascade="merge, save-update">
<key column="idProfile"/>
<index column="position"/>
<many-to-many column="idSegment"
class="Segment"/>
</array>
<array name="ratings" table="PROFILE_RATING" cascade="merge, save-update, delete">
<key column="idProfile"/>
<index column="position"/>
<many-to-many column="idRating"
class="Rating"/>
</array>
<property name="name" not-null="true" length="64"/>
</class>

Tout fonctionne bien, sauf que, pour des raisons de performance dans certains cas, je voudrais ne ramener que les "prestations" et "segment" et non les "rating"
Et il n'y a rien à faire
J'ai essayé plusiseurs choses, mais je récupère toujours toute la grappe :

Query myQuery = session.createQuery("from Profile as bp " +
"join fetch bp.prestations " +
"join fetch bp.segments order by bp.name" );


ou

Query myQuery = session.createSQLQuery(
"SELECT * FROM PROFILE bp, SEGMENT s, PRESTATION p, PROFILE_SEGMENT bps, PROFILE_PRESTATION bpp " +
"WHERE bp.idProfile=bps.idProfile AND " +
"bps.idSegment=s.idSegment AND " +
"bp.idProfile=bpp.idProfile AND " +
"bpp.idPrestation=p.idPrestation")
.addEntity(Profile.class) ;



Qlqu'un aurait-il une idée, svp ?
Merci d'avance


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 06, 2007 8:35 am 
Expert
Expert

Joined: Thu Sep 04, 2003 8:23 am
Posts: 368
N'utilise pas un array mais plutôt une liste ou un bag. Pour les array il n'y a pas de lazy loading

_________________
Seb
(Please don't forget to give credits if you found this answer useful :)


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.