I have a .NET C # project on which I use properties to map my objects to NHibernate mapping my tables Was working on in my databases. Now understand what my problem is. I have two mapped squares, for example class A and Classbie in my database, in table A there is a foreign key that refers to the primary key of the table. Therefore, I have added a frequency of classmap map to the class from one to the other: When I'm reaching class A, then I have to check the value of the area of Classbie. I will write the query in HQL: SQL generated here: I thought that this kind of HQL query was supposed to add a statement rather than a statement, as I have many between the two sections -One has defined the union. Something like this would have been better: in Meri Ray, where does the cleaner If there is a way to set the behavior of NHibernate accordingly, HQL query clearly set to join in the statement Without knowing you want to know. Any help would be appreciated!
Personal Class B; [ManyToOne (0, name = "B" columns = "ID_TABLE_B_TABLE_A" class = "ClassB" update = false, insert = false)] public virtual ClassB B {{get return b; } Set {b = value; }}
session. Creating ("Select from class a.Id where a.ClassB.Name = 'xxx'");
TABLE_A select col_0_0_ as tablea0_.ID_TABLE_A the tablea0_, TABLE_B tableb1_ where tablea0_.ID_TABLE_B_TABLE_A = tableb1_.ID_TABLE_B and tableb1_ .NAME_TABLE_B = 'Xxx'
select tablea0_.ID_TABLE_A from TABLE_A left col_0_0_ tablea0_ as joining TABLE_B tableb1_ tableb1_.ID_TABLE_B = tablea0_.ID_TABLE_B_TABLE_A where tableb1_.NAME_TABLE_B = 'xxx'
works in this way: Of course, it is for you to find out who is involved in doing the best thing for you :) More info @
Session. CreateQuery ("select from a.Id ClassA one, join A.ClassB b where b.Name = 'xxx'"); Session Creating an ID from "Creating a class." (Class B.B. where b.Name = 'xxx' "); Session Creativity ("Choose an ID from the class that is in the left outer a.ClassB b where b.Name = 'xxx'");
var results = session. ; Class A & gt; (). Where (a = & gt; aNAname == 'xxx'). ToList (); will generate an internal query.
Comments
Post a Comment