Is this a bug or am I doing something wrong?
QueryOver disjunction on Field mapped from Formula throws Object Null
Exception but is field mapped normally it works
Also, does not make a difference if I am Eager fetching or not and the
actual query which would be issued to sql server does work
*Message Mapping - *
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class xmlns="urn:nhibernate-mapping-2.2" dynamic-update="true"
name="DriverTech.NH.Entities.Message, DriverTech.NH, Version=1.0.4.19900,
Culture=neutral, PublicKeyToken=null" table="DTECH_Msg">
<id name="Id" type="System.Int32, mscorlib, Version=4.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089">
<column name="msgID" />
<generator class="identity" />
</id>
<property name="MsgType" type="System.Int32, mscorlib, Version=4.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089">
<column name="msgType" />
</property>
SNIPPED
<many-to-one class="DriverTech.NH.Entities.TruckPCBase, DriverTech.NH,
Version=1.0.4.19900, Culture=neutral, PublicKeyToken=null"
name="TruckPCBase" not-found="ignore">
<column name="truckPCID" />
</many-to-one>
<many-to-one class="DriverTech.NH.Entities.DriverBase, DriverTech.NH,
Version=1.0.4.19900, Culture=neutral, PublicKeyToken=null"
name="DriverBase" not-found="ignore" formula=" CASE WHEN UserId = 0 THEN
NULL ELSE UserId END " />
<many-to-one class="DriverTech.NH.Entities.ManagerBase, DriverTech.NH,
Version=1.0.4.19900, Culture=neutral, PublicKeyToken=null"
name="ReadByManager" not-found="ignore" formula=" CASE WHEN readManagerId
< 1 THEN NULL ELSE readManagerId END " />
<many-to-one class="DriverTech.NH.Entities.ManagerBase, DriverTech.NH,
Version=1.0.4.19900, Culture=neutral, PublicKeyToken=null"
name="FromManager" not-found="ignore">
<column name="fromManagerID" not-null="false" />
</many-to-one>
<many-to-one class="DriverTech.NH.Entities.ManagerBase, DriverTech.NH,
Version=1.0.4.19900, Culture=neutral, PublicKeyToken=null" name="ToManager"
not-found="ignore">
<column name="toManagerID" not-null="false" />
</many-to-one>
</class>
</hibernate-mapping>
*Code creating query over:*
T typeAlias = null;
var vehicleSubquery =
NHibernate.Criterion.QueryOver.Of<ReportingGroupMembersDistinctByManager>()
.Where(v => v.GroupType == ReportingGroupType.Vehicle)
.And(v => v.ManagerId == filter.PortalUserId)
.And(v => v.RecordId == typeAlias.TruckPCBase.Id)
.Select(Projections.Constant(0));
var driverSubquery =
NHibernate.Criterion.QueryOver.Of<ReportingGroupMembersDistinctByManager>()
.Where(v => v.GroupType == ReportingGroupType.User)
.And(v => v.ManagerId == filter.PortalUserId)
.And(v => v.RecordId == typeAlias.DriverBase.Id)
.Select(Projections.Constant(0));
query = Session.QueryOver<T>(() => typeAlias)
.Where(Restrictions.Disjunction()
.Add(Subqueries.WhereExists(vehicleSubquery))
.Add(Subqueries.WhereExists(driverSubquery)))
;
*Exception stack:*
at NHibernate.Persister.Entity.AbstractPropertyMapping.ToColumns(String
alias, String propertyName)
at
NHibernate.Persister.Entity.BasicEntityPropertyMapping.ToColumns(String
alias, String propertyName)
at NHibernate.Persister.Entity.AbstractEntityPersister.ToColumns(String
alias, String propertyName)
at
NHibernate.Loader.Criteria.CriteriaQueryTranslator.GetColumns(ICriteria
subcriteria, String propertyName)
at
NHibernate.Loader.Criteria.CriteriaQueryTranslator.GetColumnsUsingProjection(ICriteria
subcriteria, String propertyName)
at
NHibernate.Loader.Criteria.CriteriaQueryTranslator.GetColumnsUsingProjection(ICriteria
subcriteria, String propertyName)
at
NHibernate.Criterion.CriterionUtil.GetColumnNamesUsingPropertyName(ICriteriaQuery
criteriaQuery, ICriteria criteria, String propertyName)
at NHibernate.Criterion.CriterionUtil.GetColumnNames(String
propertyName, IProjection projection, ICriteriaQuery criteriaQuery,
ICriteria criteria, IDictionary`2 enabledFilters)
at NHibernate.Criterion.PropertyExpression.ToSqlString(ICriteria
criteria, ICriteriaQuery criteriaQuery, IDictionary`2 enabledFilters)
at
NHibernate.Loader.Criteria.CriteriaQueryTranslator.GetWhereCondition(IDictionary`2
enabledFilters)
at
NHibernate.Loader.Criteria.CriteriaJoinWalker..ctor(IOuterJoinLoadable
persister, CriteriaQueryTranslator translator, ISessionFactoryImplementor
factory, ICriteria criteria, String rootEntityName, IDictionary`2
enabledFilters)
at NHibernate.Criterion.SubqueryExpression.ToSqlString(ICriteria
criteria, ICriteriaQuery criteriaQuery, IDictionary`2 enabledFilters)
at NHibernate.Criterion.Junction.ToSqlString(ICriteria criteria,
ICriteriaQuery criteriaQuery, IDictionary`2 enabledFilters)
at
NHibernate.Loader.Criteria.CriteriaQueryTranslator.GetWhereCondition(IDictionary`2
enabledFilters)
at
NHibernate.Loader.Criteria.CriteriaJoinWalker..ctor(IOuterJoinLoadable
persister, CriteriaQueryTranslator translator, ISessionFactoryImplementor
factory, ICriteria criteria, String rootEntityName, IDictionary`2
enabledFilters)
at NHibernate.Loader.Criteria.CriteriaLoader..ctor(IOuterJoinLoadable
persister, ISessionFactoryImplementor factory, CriteriaImpl rootCriteria,
String rootEntityName, IDictionary`2 enabledFilters)
at NHibernate.Impl.MultiCriteriaImpl.CreateCriteriaLoaders()
at NHibernate.Impl.MultiCriteriaImpl.List()
at NHibernate.Impl.FutureCriteriaBatch.GetResultsFrom(IMultiCriteria
multiApproach)
at NHibernate.Impl.FutureBatch`2.GetResults()
at NHibernate.Impl.FutureBatch`2.get_Results()
at NHibernate.Impl.FutureBatch`2.GetCurrentResult[TResult](Int32
currentIndex)
at
NHibernate.Impl.FutureBatch`2.<>c__DisplayClass1`1.<GetFutureValue>b__0()
at NHibernate.Impl.FutureValue`1.get_Value()
at DriverTech.NH.Repositories.PagedResult`1.Paginate(IQueryOver`2
queryOver, GridDataFilter filter) in
C:\Projects\DriverTech\WebServices\FWAPI\DriverTech.NH\Repositories\PagedResult.cs:line
53
at DriverTech.NH.Repositories.LinqExtensions.Paginate[T](IQueryOver`2
query, GridDataFilter filter) in
C:\Projects\DriverTech\WebServices\FWAPI\DriverTech.NH\Repositories\LinqExtensions.cs:line
66
at
DriverTech.NH.Repositories.Data.MessageRepository.<>c__DisplayClass1.<Get_Paged>b__0()
in
C:\Projects\DriverTech\WebServices\FWAPI\DriverTech.NH\Repositories\Data\MessageRepository.cs:line
96
at DriverTech.NH.Repositories.Repository`1.Transact[TResult](Func`1
func, IsolationLevel isolationLevel) in
C:\Projects\DriverTech\WebServices\FWAPI\DriverTech.NH\Repositories\RepositoryBase.cs:line
626
at
DriverTech.NH.Repositories.Data.MessageRepository.Get_Paged(GridDataFilter
filter, Nullable`1 viewInboundOnly, Nullable`1 viewReadOnly) in
C:\Projects\DriverTech\WebServices\FWAPI\DriverTech.NH\Repositories\Data\MessageRepository.cs:line
96
at DriverTech.Execution.MessageProcessor.Process(PagedRequestForJQGrid
pagedRequest, Nullable`1 viewInboundOnly, Nullable`1 viewReadOnly, Int32&
TotalRowCount) in
C:\Projects\DriverTech\WebServices\FWAPI\DriverTech.Execution\MessageProcessor2.cs:line
97
*Query which should be issued to sql server:*
SELECT TOP (60 /* @p7 */) this_.msgID as msgID43_5_,
this_.msgType as msgType43_5_,
this_.iTime as iTime43_5_,
this_.time as time43_5_,
this_.bInbound as bInbound43_5_,
this_.status as status43_5_,
this_._to as column7_43_5_,
this_._from as column8_43_5_,
this_.subject as subject43_5_,
this_.body as body43_5_,
this_.rxTime as rxTime43_5_,
this_.formID as formID43_5_,
this_.stateID as stateID43_5_,
this_.readTime as readTime43_5_,
this_.priority as priority43_5_,
this_.transport as transport43_5_,
this_.bWantReceipt as bWantRe17_43_5_,
this_.receiptTime as receipt18_43_5_,
this_.iCustomerLink as iCustom19_43_5_,
this_.szCustomerLink as szCusto20_43_5_,
this_.bVolumeOverride as bVolume21_43_5_,
this_.replyID as replyID43_5_,
this_.bImportant as bImportant43_5_,
this_.DataXml as DataXml43_5_,
this_.bHasAttachment as bHasAtt25_43_5_,
this_.fromManagerID as fromMan26_43_5_,
this_.toManagerID as toManag27_43_5_,
CASE
WHEN this_.truckPCID < 1 THEN NULL
ELSE this_.truckPCID
END as formula3_5_,
CASE
WHEN this_.UserId = 0 THEN NULL
ELSE this_.UserId
END as formula4_5_,
CASE
WHEN this_.readManagerId < 1 THEN NULL
ELSE this_.readManagerId
END as formula5_5_,
truckpcbas2_.truckPCID as truckPCID71_0_,
truckpcbas2_.truckName as truckName71_0_,
driverbase3_.userID as userID25_1_,
driverbase3_.employeeID as employeeID25_1_,
driverbase3_.logon as logon25_1_,
driverbase3_.driverName as driverName25_1_,
driverbase3_.bDeleted as bDeleted25_1_,
driverbase3_.timezone as timezone25_1_,
driverbase3_.buseDaylightSavings as buseDayl7_25_1_,
managerbas4_.ManagerId as ManagerId40_2_,
managerbas4_.Login as Login40_2_,
managerbas4_.Name as Name40_2_,
managerbas5_.ManagerId as ManagerId40_3_,
managerbas5_.Login as Login40_3_,
managerbas5_.Name as Name40_3_,
managerbas6_.ManagerId as ManagerId40_4_,
managerbas6_.Login as Login40_4_,
managerbas6_.Name as Name40_4_
FROM dbo.DTECH_Msg this_
left outer join dbo.vwVehicleSimple truckpcbas2_
on CASE
WHEN this_.truckPCID < 1 THEN NULL
ELSE this_.truckPCID
END = truckpcbas2_.truckPCID
left outer join dbo.vwDriverSimple driverbase3_
on CASE
WHEN this_.UserId = 0 THEN NULL
ELSE this_.UserId
END = driverbase3_.userID
left outer join dbo.DTECH_Managers managerbas4_
on CASE
WHEN this_.readManagerId < 1 THEN NULL
ELSE this_.readManagerId
END = managerbas4_.ManagerId
left outer join dbo.DTECH_Managers managerbas5_
on this_.fromManagerID = managerbas5_.ManagerId
left outer join dbo.DTECH_Managers managerbas6_
on this_.toManagerID = managerbas6_.ManagerId
WHERE
(exists (
/* criteria query */ SELECT 0 /* @p0 */ as y0_
FROM dbo.vwReportingGroupsMembers_GetDistinctByManagerId
this_0_
WHERE this_0_.GroupType = 1 /* @p1 */
and this_0_.ManagerId = 34 /* @p2 */
and this_0_.RecordId = this_.truckPCID)
or exists (
/* criteria query */ SELECT 0 /* @p3 */ as y0_
FROM
dbo.vwReportingGroupsMembers_GetDistinctByManagerId this_0_
WHERE this_0_.GroupType = 0 /* @p4 */
and this_0_.ManagerId = 34 /* @p5 */
and this_0_.RecordId = this_.userID))
and(this_.msgType = 1 /* @p8 */
or this_.msgType = 10 /* @p9 */)
and this_.bInbound = 1 /* @p10 */
and (((this_.bInbound = 1 /* @p11 */
and this_.readTime is null)
or ((this_.bInbound = 0 /* @p12 */
and this_.receiptTime is null)
and this_.bWantReceipt = 1 /* @p13 */))
or (this_.bInbound = 0 /* @p14 */
and this_.rxTime is null));
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/d/optout.