Version 1.2 CR1
I have had two problems with unit testing NHib using SqlCE today and wonder if anyone else has come across these. One seems to be a NHib dialect issue and the other a SqlCE issue (perhaps a limitation).
First, I have two components embedded in a mapping that works just fine in Sql Server 2005, but there is just an ambiguous 'Cannot map entity' Nhib.ADOException when trying to save/load the entity. I made a change to the inner dictionary of the components and while it brought in the parent object (PlasticityIndex) it didn't hydrate the components. I checked the sql issued and it is fine (the sql for the components is generated).
Here is the mapping. :
Code:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
assembly="@core.assembly@"
default-access="nosetter.camelcase-underscore" default-lazy="false">
<class name="Cei.eMerge.Core.Domain.MaterialsTesting.PlasticityIndex"
table="PlasticityIndex" >
<id name="Id" access="property" unsaved-value="0" >
<column name="Id"/>
<generator class="native" />
</id>
<many-to-one name="Sample" class="Cei.eMerge.Core.Domain.MaterialsTesting.MaterialsSample" not-null="true" >
<column name="SampleId"/>
</many-to-one>
<property name="NonPlastic"/>
<property name="Value"/>
<component name="AASHTO_T89" class="Cei.eMerge.Core.Domain.MaterialsTesting.AASHTO_T89" >
<property name="AverageLiquidLimit" />
<map name="_pans" access="field" table="AASHTO_T89Pan">
<key foreign-key="PlasticityIndex_AASHTO_T89Pan">
<column name="PlasticityIndexId"/>
</key>
<index type="System.String">
<column name="Method"/>
</index>
<composite-element class="Cei.eMerge.Core.Domain.MaterialsTesting.LiquidLimitPan">
<property name="PanNumber"/>
<property name="TareWeight"/>
<property name="WetWeightWithPan"/>
<property name="DryWeightWithPan"/>
<property name="XLimit"/>
<property name="NumberOfBlows"/>
<property name="Factor"/>
</composite-element>
</map>
</component>
<component name="AASHTO_T90" class="Cei.eMerge.Core.Domain.MaterialsTesting.AASHTO_T90" >
<property name="AveragePlasticLimit" />
<map name="_pans" access="field" table="AASHTO_T90Pan">
<key foreign-key="PlasticityIndex_AASHTO_T90Pan">
<column name="PlasticityIndexId"/>
</key>
<index type="System.String">
<column name="Method"/>
</index>
<composite-element class="Cei.eMerge.Core.Domain.MaterialsTesting.PlasticityIndexPan">
<property name="PanNumber"/>
<property name="TareWeight"/>
<property name="WetWeightWithPan"/>
<property name="DryWeightWithPan"/>
<property name="XLimit"/>
</composite-element>
</map>
</component>
</class>
</hibernate-mapping>
What would cause Sql Server 2005 to hydrate the objects just in SqlCE the components are ignored?
Next problem, SqlCE doesn't seem to be supporting nested subqueries:
Stack trace:
Code:
NHibernate.ADOException: could not execute query
[ SELECT this_.Id as Id11_2_, this_.DateCreated as DateCrea3_11_2_, this_.LastModified as LastModi4_11_2_, ... [more properties]
FROM Contact this_ inner join ContactAssociation associatio1_ on this_.Id=associatio1_.ContactId left outer join Contact contact4_ on associatio1_.Associate_ContactId=contact4_.Id WHERE exists (SELECT this_0_.Id as y0_ FROM ContactAssociation this_0_ inner join Contact associate1_ on this_0_.Associate_ContactId=associate1_.Id WHERE associate1_.Id = (SELECT this_0_0_.Id as y0_ FROM Contact this_0_0_ WHERE this_0_0_.Id = ? and this_0_0_.Id = associate1_.Id) and associate1_.Id = associatio1_.Id) ]
Positional parameters: 0 3
[SQL: SELECT this_.Id as Id11_2_,...[more properties] FROM ContactAssociation this_0_ inner join Contact associate1_ on this_0_.Associate_ContactId=associate1_.Id WHERE associate1_.Id = (SELECT this_0_0_.Id as y0_ FROM Contact this_0_0_ WHERE this_0_0_.Id = ? and this_0_0_.Id = associate1_.Id) and associate1_.Id = associatio1_.Id)]
at NHibernate.Loader.Loader.DoList(ISessionImplementor session, QueryParameters queryParameters)
at NHibernate.Loader.Loader.List(ISessionImplementor session, QueryParameters queryParameters, ISet querySpaces, IType[] resultTypes)
at NHibernate.Impl.SessionImpl.Find(CriteriaImpl criteria, IList results)
at NHibernate.Impl.SessionImpl.Find[T](CriteriaImpl criteria)
at NHibernate.Impl.CriteriaImpl.List[T]()
at Cei.eMerge.Common.NHRepository`1.FindAll(DetachedCriteria criteria, Order[] orders) in NHRepository.cs:line 131
at Cei.eMerge.Common.NHInterceptedRepository`1.FindAll(DetachedCriteria criteria, Order[] orders) in NHInterceptedRepository.cs:line 52
at Cei.eMerge.Core.Domain.MaterialsTesting.SieveAnalysisDataSpecificationQueryTest.CanFindContactByAssociationAndType() in SieveAnalysisDataSpecificationQueryTest.cs:line 585
System.Data.SqlServerCe.SqlCeException: There was an error parsing the query. [ Token line number = 1,Token line offset = 1743,Token in error = SELECT ]
at System.Data.SqlServerCe.SqlCeCommand.CompileQueryPlan()
at System.Data.SqlServerCe.SqlCeCommand.ExecuteCommand(CommandBehavior behavior, String method, ResultSetOptions options)
at System.Data.SqlServerCe.SqlCeCommand.ExecuteDbDataReader(CommandBehavior behavior)
at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader()
at NHibernate.Impl.BatcherImpl.ExecuteReader(IDbCommand cmd)
at NHibernate.Loader.Loader.GetResultSet(IDbCommand st, RowSelection selection, ISessionImplementor session)
at NHibernate.Loader.Loader.DoQuery(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies)
at NHibernate.Loader.Loader.DoQueryAndInitializeNonLazyCollections(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies)
at NHibernate.Loader.Loader.DoList(ISessionImplementor session, QueryParameters queryParameters)