You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We use the LINQ Provider with the FetchMany extension to reduce the roundtrips to the database and the amount of data. Unfortunately it is not possible to filter the fetched association like FetchMany(x => x.MyAssociation.Where(...)) , so we tried to use the Filter in the Mapping files. This seems to work, but the problem is, that for every out filtered element, there is a select statement in the log file. Is it really necessary to create a extra select there? We use the Version 5.2.1.
This is the created select statement:
select
asset0_.pdoid as pdoid1_0_0_,
dokument2_.pdoid as pdoid1_0_1_,
asset0_.IsDeleted as isdeleted2_0_0_,
dokument2_.IsDeleted as isdeleted2_0_1_,
dokumente1_.AssetId as assetid1_4_0__,
dokumente1_.DokumentId as dokumentid2_4_0__
from
Asset asset0_
left outer join
asset_to_dokument dokumente1_
on asset0_.pdoid=dokumente1_.AssetId
left outer join
Dokument dokument2_
on dokumente1_.DokumentId=dokument2_.pdoid
and dokument2_.IsDeleted = @p0
where
asset0_.IsDeleted = @p0;
@p0 = False [Type: Boolean (0:0:0)]
And for every deleted "Dokument" (for example 1000 elements) there is a statement like this:
SELECT
dokument0_.pdoid as pdoid1_0_0_,
dokument0_.IsDeleted as isdeleted2_0_0_
FROM
Dokument dokument0_
WHERE
dokument0_.pdoid=@p0;
@p0 = 32783 [Type: Int64 (0:0:0)]
This is my model:
public class Base
{
public virtual long Key { get; set; }
public virtual bool IsDeleted { get; set; }
}
public class Asset : Base
{
public virtual ISet<Dokument> Dokumente { get; set; }
}
public class Dokument : Base
{
public virtual ISet<Asset> Assets { get; set; }
}
using (ISession s = OpenSession())
using (ITransaction t = s.BeginTransaction())
{
s.EnableFilter("deletedFilter").SetParameter("deletedParam", false);
var assets = s.Query<Asset>()
.FetchMany(x => x.Dokumente)
.ToList();
}
The text was updated successfully, but these errors were encountered:
Are you sure that loaded asset.Dokumente doesn't contain deleted documents? As from query it seems
that asset_to_dokument records are still loaded for deleted documents. And then you see lazy loading requests for all deleted Dokument records
It seems to work properly bridge tables for many-to-many association need to be inner joined (asset_to_dokument and Dokument)
You are right, the deleted documents are still loaded into the object model.
Is this my fault, or it is a bug?
I can't change the structure of the "bridge table".
It's a bug. And my inner join suggestion is obviously wrong (as it will filter asset records too).
From what I see it's hql/Query related. QueryOver/Criteria case seems to be working correctly:
s.EnableFilter("deletedFilter").SetParameter("deletedParam",false);varassets=s.QueryOver<Asset>().Fetch(SelectMode.Fetch, x =>x.Dokumente).TransformUsing(Transformers.DistinctRootEntity).List<Asset>();
We use the LINQ Provider with the FetchMany extension to reduce the roundtrips to the database and the amount of data. Unfortunately it is not possible to filter the fetched association like
FetchMany(x => x.MyAssociation.Where(...))
, so we tried to use the Filter in the Mapping files. This seems to work, but the problem is, that for every out filtered element, there is a select statement in the log file. Is it really necessary to create a extra select there? We use the Version 5.2.1.This is the created select statement:
And for every deleted "Dokument" (for example 1000 elements) there is a statement like this:
This is my model:
This is my mapping:
This is my LINQ Statement:
The text was updated successfully, but these errors were encountered: