|
From: Peter K. (JIRA) <nh...@gm...> - 2011-06-30 21:23:48
|
NHibernate does extra select on each missing relations, even using an eager fetching.
-------------------------------------------------------------------------------------
Key: NH-2784
URL: http://216.121.112.228/browse/NH-2784
Project: NHibernate
Issue Type: Bug
Components: Core
Affects Versions: 3.1.0
Reporter: Peter Kiers
When I do an eager join on a relation table, whenever the relation is missing it will generate an additional query for each missing relation.
Table layout / data:
TableName: Order
+----+-----------+--------+
| Id | OrderName | UserId |
+----+-----------+--------+
| 1 | OrderA | 1 |
| 2 | OrderB | 2 |
| 3 | OrderC | 3 |
+-------------------------+
TableName: User
+----+-----------+
| Id | UserName |
+----+-----------+
| 1 | User1 |
| 2 | User2 |
+----------------+
var orders = session.CreateCriteria<Order>().SetFetchMode("User",
FetchMode.Eager).List<Order>();
Console output:
NHibernate: SELECT this_.Id as Id0_1_, this_.OrderName as OrderName0_1_, this_.User_id as User3_0_1_, user2_.Id as Id1_0_, user2_.UserName as UserName1_0_ FROM[Order] this_ left outer join [User] user2_ on this_.User_id=user2_.Id
NHibernate: SELECT user0_.Id as Id1_0_, user0_.UserName as UserName1_0_ FROM [User] user0_ WHERE user0_.Id=@p0;@p0 = 3 [Type: Int32 (0)]
As you can see it tries to get UserID 3 (which doesn't exists) but it should already know it isn't there as I did a eager fetchmode on that table.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://216.121.112.228/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
|