Fetch=join to tables to one class NHibernate?

This isn't doing what you think it's doing. Using fetch=join is just there to eager load the many side of the relationship. In both cases you end up with the same objects returned.By default Nbernate will lazy load the related entities (which is why you get the second query).

By using fetch=join you are asking for the entire object relationship at once but it will still populate the objects the same as without the fetch=join.

I don't understand your question. The 'fetch-join' attribute just defines how the sql that Nbernate generates to retrieve instances of your classes, should look like. It has nothing to do with 'what' will be returned.

Nbernate will translate the recordset (that is the result of the query) to correct instances of your classes. If you just want to retrieve parts of your entity (like the name for instance), then you'll have to write a HQL query, or use the ICriteria API and maybe use projections.

I want fix this item only by mapping, that is why ICriteria API and projections aren't suit. – Kate Oct 9 '09 at 12:26 Then, you'll have to create new class, which only contains the properties you're interested in, and map this class to the table(s). But, I would not recommend this approach.

Why is using hql or icriteria not an option? – Frederik Gheysels Oct 9 '09 at 12:38 I edit post above to explain. – Kate Oct 9 '09 at 13:10.

It's not the way you describe it. Your entities do not change depending on what you request. You will obtain a list of instances of your main entity, with the association to the other being fetched.So if, in your code, you access the association, you will find the values.

If you don't fetch it, you wouldn't be able to access those fields, as they would not have been retrieved from the database.

I understand, thank you. But then what I can do? – Kate Oct 9 '09 at 12:28 I know that your mappings are not correct for regular I'm not sure for N I don't see your association... Sorry, I don't have an environment to test that right now, to help you :-( – KLE Oct 9 '09 at 12:51.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions