B is not using projection, it is using a fetching strategy which will load it eagerly when needed and will leave the lazy loading if you are not going to request this data in the use case.
If you don't know at first what you need to get from an object you are in big trouble, you should always know which information you are going to need in a use case. Gustavo. On Fri, Mar 27, 2009 at 3:58 PM, Peter Morris <[email protected]> wrote: > > Let's say I have an object with an association to a single object and the > mapping doesn't specify that NH should fetch the associated object > automatically. Now when my app layer fetches that object and wants to do > some processing on it (which uses that association) I must either > > A: Use proxies, mark my property virtual, and perform the processing within > the life of the session from which it was retrieved. > B: Use projection to ensure that the associated object is also fetched. > > Is that right? > > I'm put off by A because I don't like making my properties virtual unless > there is a logical reason within the domain to do so rather than because > the > persistence layer requires it. I am also not sure about the idea of using > Proxies, I don't recall the details now but I remember reading about > problems with proxies and polymorhpic associations. I think it was because > each proxy in the list is a proxy of the base class and not a proxy of each > sub-class depending on the actual type of the instance in the association? > > I am put off by B for two reasons. Firstly the code to retrieve the object > would really need to either fetch as much information as possible or would > need intimiate knowledge of the method about to be executed because it > needs > to know what to fetch from the DB. If at a later point the implementation > of the method changed and required additional state then there would need > to > be an update to any code which retrieved the object from the DB before > passing the object to the method. > > Hopefully I am mistaken and have misunderstood something :-) > > > Pete > ==== > http://mrpmorris.blogspot.com > > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~----------~----~----~----~------~----~------~--~---
