-->
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: NHibernate many-to-one-or-zero , keeps trying to select
PostPosted: Mon May 25, 2009 4:03 am 
Newbie

Joined: Mon May 25, 2009 3:05 am
Posts: 1
Hi

Iam struggling with NHibernate and its lazyload.

I have a structure which I simplified but it show my issue.

Code:
Class Shift {
   int ShiftID;
   DateTime ShiftStart;
   Employee Employee;
}
Class Employee {
   int EmployeeID;
   string Name;
}


Data:
    ShiftData
    ID SHIFTTIME EmployeeID (int)
    1 12:00 0
    2 13:00 1
    3 14:00 0
    4 13:00 3


    Employees
    ID NAME
    1 Morten
    2 Peter
    3 Henrik

My loading strategy for the shift is using Join so that when I load the shifts NHibernate automatically does a Left join to get the customer. This works perfectly for the shifts with Employees attached, however some shifts haven’t got any employees yet.

When I try to access the Employee of such a shift once the shift is loaded it results in another SELECT against the database

Why does this happen ?

Hope you have an answer iam really stuck on this.


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.