*Hi, *
*
*
*This is the mapping of my Meeting class: *
<hibernate-mapping namespace="CDER_ChoixAccesPolesGEDModel.Model"
assembly="CDER_ChoixAccesPolesGEDModel" xmlns="urn:nhibernate-mapping-2.2">
<class name="Meeting" table="`meeting`" schema="`test`" >
<composite-id>
<key-many-to-one class="Person1" column="idPerson" name="Person"
access="property" ></key-many-to-one>
* <key-many-to-one class="Room" column="idRoom" name="Room"
access="property" lazy="false" ></key-many-to-one>*
<key-many-to-one class="Person2" column="idPerson2" name="Person"
></key-many-to-one>
</composite-id>
<property column="dateStart" name="DateStart" access="property"
not-null="false"></property>
<property column="dateFinish" name="DateFinish" access="property"
not-null="false"></property>
</class>
</hibernate-mapping>
*By default, lazy=true, so i will have a proxy for Person1 and Person2.*
*
*
*If i request a meeting like this : *
List<Meeting> agents = new List<Meeting>(Session.Query<Meeting>().
Where(a => a.Room.idRoom == 1)
.Fetch(d=>d.*Room*)
.ToList());
*or like this : *
List<Meeting> agents2 = _QueryDAO.RequeterListe<Meeting>(
"SELECT m FROM Meeting m " +
"JOIN FETCH i.Room r" +
"WHERE r.idRoom=1 " );
*I have a first generated SQL request like this for LINQ:*
SELECT *
FROM `test`.`Meeting` m
LEFT OUTER JOIN `test`.`Room` r on m.idRoom=r.`idRoom`
WHERE r.`idRoom`=1
*or like this for HQL : *
*
*
SELECT *
FROM `test`.`Meeting` m
INNER JOIN `test`.`Room` r on m.idRoom=r.`idRoom`
WHERE r.`idRoom`=1
*
*
*And a second automatic request (n+1) : *
SELECT *
FROM `test`.`Room` r
WHERE r.`idRoom`=1
*
*
*After having request, my object Person1 and Person2 are Proxy, which is
normal with lazy defaut to true and my object Room is correctly loaded.*
*But, it need a second request, I know the attribut join (which is
not available in a key-many-to-one) is set to "select" by default.*
*Ok, but if i fetch in my linq or HQL query, why a second request is
excuted ?*
*
*
*
*
*
*
*Now, If i request a meeting like this : *
List<Meeting> agents = new List<Meeting>(Session.Query<Meeting>().
Where(a => a.Person1.idPerson == 2)
.Fetch(d=>d.*Room*).Fetch(a=>a.Person1).Fetch(f=>f.Person2)
.ToList());
*or like this : *
List<Meeting> agents2 = _QueryDAO.RequeterListe<Meeting>(
"SELECT m FROM Meeting m " +
" JOIN FETCH i.Person1 p1 " +
" JOIN FETCH i.Room r" +
" JOIN FETCH i.Person2 p2 " +
"WHERE p1.idPerson=2 " );
*I have a first generated SQL request like this :*
SELECT *
FROM `test`.`Meeting` m
INNER JOIN `test`.`Person1` p1 on m.idPerson1=p1.`idPerson`
LEFT OUTER JOIN *(OR "INNER JOIN" FOR HQL)* `test`.`Room` r on
m.idRoom=r.`idRoom`
INNER JOIN `test`.`Person2` p2 on m.idPerson2=p1.`idPerson`
WHERE intervenan0_.idpersonn=2
*
*
*And a second automatic request (n+1): *
SELECT *
FROM `test`.`Room` r
WHERE r.`idRoom`=1
*
*
*Why my Person1 and Person2 are always Proxy? I have fetch in the query..*
*
*
*
*
*There is something I do not understand? It's a bug of Nhibernate? a
feature not developed ? Or there is a reason for this behavior?*
*
*
*Thank's in advance.*
*
*
*Hawk.*
*
*
*
*
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/nhusers?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.