session load exception with enableFilter

Description

demo explain:
The BaseOn property of Pricelist is also a Pricelist class, but its property is null.

session.EnableFilter("tenant").SetParameter("id", tenantId);
session.Load<Pricelist>(pricelistId);
output:
NHibernate.Test.NHSpecificTest.NH1234.SampleTest.ShouldBeLoadedWithoutException:
NHibernate.ObjectNotFoundException : No row with the given identifier exists[NHibernate.Test.NHSpecificTest.NH1234.Pricelist#1]
---------------------------------------------------------------------------------------
EXPECTED:
SELECT pricelist0_.ID as ID0_2_, pricelist0_.TENANT_ID as TENANT2_0_2_, pricelist0_.BASED_ON as BASED3_0_2_,
pricelist0_.NAME as NAME0_2_, pricelist0_.PRECISION as PRECISION0_2_, pricelist0_.IS_ACTIVE as IS6_0_2_,
tenant1_.ID as ID1_0_, tenant1_.NAME as NAME1_0_, tenant1_.BASE_URL as BASE3_1_0_, tenant1_.TITLE as TITLE1_0_,
tenant1_.THEME as THEME1_0_, pricelist2_.ID as ID0_1_, pricelist2_.TENANT_ID as TENANT2_0_1_,
pricelist2_.BASED_ON as BASED3_0_1_, pricelist2_.NAME as NAME0_1_, pricelist2_.PRECISION as PRECISION0_1_, pricelist2_.IS_ACTIVE as IS6_0_1_
FROM Pricelists pricelist0_
inner join Tenants tenant1_ on pricelist0_.TENANT_ID=tenant1_.ID
left outer join Pricelists pricelist2_ on pricelist0_.BASED_ON=pricelist2_.ID and pricelist2_.TENANT_ID = @p0
WHERE tenant1_.ID = @p0 AND pricelist0_.ID=@p2;@p0 = 1 [Type: Int64 (0)], @p2 = 1 [Type: Int64 (0)]

BUT:
SELECT pricelist0_.ID as ID0_2_, pricelist0_.TENANT_ID as TENANT2_0_2_, pricelist0_.BASED_ON as BASED3_0_2_,
pricelist0_.NAME as NAME0_2_, pricelist0_.PRECISION as PRECISION0_2_, pricelist0_.IS_ACTIVE as IS6_0_2_,
tenant1_.ID as ID1_0_, tenant1_.NAME as NAME1_0_, tenant1_.BASE_URL as BASE3_1_0_, tenant1_.TITLE as TITLE1_0_,
tenant1_.THEME as THEME1_0_, pricelist2_.ID as ID0_1_, pricelist2_.TENANT_ID as TENANT2_0_1_,
pricelist2_.BASED_ON as BASED3_0_1_, pricelist2_.NAME as NAME0_1_, pricelist2_.PRECISION as PRECISION0_1_, pricelist2_.IS_ACTIVE as IS6_0_1_
FROM Pricelists pricelist0_
inner join Tenants tenant1_ on pricelist0_.TENANT_ID=tenant1_.ID
left outer join Pricelists pricelist2_ on pricelist0_.BASED_ON=pricelist2_.ID
WHERE tenant1_.ID = @p0 and pricelist2_.TENANT_ID = @p0 AND pricelist0_.ID=@p2;@p0 = 1 [Type: Int64 (0)], @p2 = 1 [Type: Int64 (0)]

Environment

None

Activity

Show:
gaudi
December 8, 2013, 9:12 AM
Edited

Sorry, I didn't say it clearly.
the following code:

<code>
object tenantId;
object pricelistId;

using (ISession session = this.OpenSession())
{
Tenant tenant = new Tenant();
tenant.Name = "gaudi";
tenant.BaseUrl = "http://localhost:8061/gaudi";
tenant.Theme = "gaudi";
tenant.Title = "gaudi";
tenantId = session.Save(tenant);

Pricelist pricelist = new Pricelist();
pricelist.Tenant = tenant;
pricelist.Name = "sales";
pricelist.Precision = 2;
pricelist.IsActive = true;
pricelistId = session.Save(pricelist);

session.Flush();

}

using (ISession session = this.OpenSession())
{
session.EnableFilter("tenant").SetParameter("id", tenantId);
session.Load<Pricelist>(pricelistId); //--> should be exists, but not found.
}

</code>

Alex Zaytsev
September 19, 2019, 11:40 AM

Fixed by #268

Alex Zaytsev
September 19, 2019, 11:41 AM

Moved here.

Assignee

Alex Zaytsev

Reporter

gaudi

Labels

Components

Affects versions

Priority

Major
Configure