NHibernate CreateSqlQuery and object graph -


Hello, I am a newbie for NHibernate. I want to do a SQL query in the database by joining in three tables.

I have many roles with many users. I am trying to start NHibernate with the object graph properly with the form object. For example, if I have 10 application records, then I need 10 app objects and then those objects have their roles that have users. What I'm still getting is a Cartesian product which resembles I have as many application items as in total user records.

I've seen this quite a bit and I'm not sure if this is possible as the application hierarchy correctly I can only get flat items to come back. It seems that "possibly" is possible in my research that I have read about "GROUPED JOIN" and "hierarchical output", from which the upcoming LINQ with NHibernate release Yet I am a newbie.

[Update Ayende post here is my guess based on Frans comment that is what I want to do it is not possible]

Thanks for you time in advance.

  Select a.ID, a.InternalName, r.ID, r.ApplicationID, r.Name, u.UserID, dbo from u.RoleID. [ Application] Join a [UserRoleXRef] dbo. [Roles] Running a.ID = r.ApplicationID R. dbo. U.RoleID = r.ID "on U.AddEntity (" app ", typeof (RightsBasedSecurityApplication)). AddJoin ("role" "app.roles") .AddJoin ("user", "role.RightsUsers"). LIST & LT; RightsBasedSecurityApplication & gt; () AsQueryable ();  

I just discovered the batching. It should be quite good, though using the one would be better to join in.

  returned session .createcriteria & Lt; RightsBasedSecurityApplication & gt; () .SetFetchMode ("roles", FetchMode.Select) .List & LT; RightsBasedSecurityApplication & gt; () .AsQueryable (); Public Class Writebiz Security Applications Mapping: Classmap & Lt; RightsBusageSecurity & gt; {Public Writers Security Applications Mapping (Table {"App"); Id (x => x.id, "id"); // column ("id"); Map (x = & gt; x.InternalName); HasMany (x = & gt; x.Roles). Batchies (10); Role of the public class: Mapping: Classmaker & lt; Role & gt; {Public Role Mapping () {Table ("Roles"); Id (x = & gt; x.id, "id"); References (x => x.application, "applicationID") Not.LazyLoad () .; Map (x = & x; x.Name); HasMany (X = & gt; x.RightsUsers). .table ("UserRoleXRef") BatchSize (100);  

Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -