I’m wondering if this is the right way to use second-level caching along with eagerly loading a collection.
This code is equivalent to a query that we are issuing from a fairly large application. I’ve stripped it down to the very minimum while still throwing the exception.
(My apologies for the rather large email, but I want to provide as much information up-front as possible)
I have this test set up:
[TestMethod]
public void FindWithFetchAndCacheableTest()
{
IPersistenceService ps = PersistenceServiceFactory.CreateService(PersistenceServiceType.Hibernate);
IList<ParentObject> pos = ps.Find<ParentObject, IQueryable<ParentObject>>(ParentObjects =>
from po in ParentObjects
select po)
.Cacheable()
.Fetch(po => po.ChildObjects).ToList();
Assert.IsTrue(pos.Count > 0);
}
My uneducated guess:
--------------------------------------
The lambda expression in Fetch() is being used as a ‘resultTransfomer’ here:
(NHibernate.Hql.Ast.ANTLR.Loader.QueryLoader.cs:line 335, using NH3.0.0Alpha1)
protected override object GetResultColumnOrRow(object[] row, IResultTransformer resultTransformer, IDataReader rs,
ISessionImplementor session)
{
row = ToResultRow(row); <-- after this assignment, row is an Array[1] holding my object
bool hasTransform = HasSelectNew || resultTransformer != null; <-- at this point, resultTransformer has a lambda
…
else if (!hasTransform)
{
return row.Length == 1 ? row[0] : row; <-- the object is not extracted from the array, because of the lambda
}
}
And this method ends up returning an array (object[1] = [{ ParentObject}]), instead of returning the object itself.
Then later on, since the ‘object[1]’ array doesn’t have an ‘Id’ property, this line throws the exception:
(NHibernate.Properties.BasicPropertyAccessor.cs:Line 207 (BasicGetter.Get)):
public object Get(object target)
{
try
{
return property.GetValue(target, new object[0]); <-- target is not {ParentObject}, but an object[1] instead
}
catch (Exception e)
{
throw new PropertyAccessException(e, "Exception occurred", false, clazz, propertyName);
}
}
My classes:
------------------------------------------------------
public class ParentObject
{
public virtual int Id { get; set; }
public virtual string Name { get; set; }
public virtual ISet<ChildObject> ChildObjects { get; set; }
public virtual void AddChildObject(ChildObject co)
{
this.ChildObjects.Add(co);
co.Parent = this;
}
}
public class ChildObject
{
public virtual int Id { get; set; }
public virtual string Name { get; set; }
public virtual ParentObject Parent { get; set; }
}
Mappings:
----------------------------------------
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" auto-import="true">
<class name="PersistenceLayer.Test.Model.ParentObject, PersistenceLayer.Test">
<cache usage="read-write"/>
<id name="Id">
<generator class="native"/>
</id>
<property name="Name"/>
<set name="ChildObjects" inverse="true" cascade="all-delete-orphan">
<cache usage="read-write"/>
<key column="ParentId"/>
<one-to-many class="PersistenceLayer.Test.Model.ChildObject"/>
</set>
</class>
</hibernate-mapping>
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" auto-import="true">
<class name="PersistenceLayer.Test.Model.ChildObject, PersistenceLayer.Test">
<cache usage="read-write"/>
<id name="Id">
<generator class="native"/>
</id>
<property name="Name"/>
<many-to-one name="Parent" column="ParentId" not-null="true"/>
</class>
</hibernate-mapping>
But it throws this exception:
Test method PersistenceLayer.Test.PersistenceServiceTest.FindWithFetchAndCacheableTest threw exception: NHibernate.PropertyAccessException: Exception occurred getter of PersistenceLayer.Test.Model.ParentObject.Id ---> System.Reflection.TargetException: Object does not match target type..
System.Reflection.RuntimeMethodInfo.CheckConsistency(Object target)
System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
System.Reflection.RuntimePropertyInfo.GetValue(Object obj, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture)
System.Reflection.RuntimePropertyInfo.GetValue(Object obj, Object[] index)
NHibernate.Properties.BasicPropertyAccessor.BasicGetter.Get(Object target) in d:\CSharp\NH\nhibernate\src\NHibernate\Properties\BasicPropertyAccessor.cs: line 207
NHibernate.Properties.BasicPropertyAccessor.BasicGetter.Get(Object target) in d:\CSharp\NH\nhibernate\src\NHibernate\Properties\BasicPropertyAccessor.cs: line 211
NHibernate.Tuple.Entity.AbstractEntityTuplizer.GetIdentifier(Object entity) in d:\CSharp\NH\nhibernate\src\NHibernate\Tuple\Entity\AbstractEntityTuplizer.cs: line 139
NHibernate.Persister.Entity.AbstractEntityPersister.GetIdentifier(Object obj, EntityMode entityMode) in d:\CSharp\NH\nhibernate\src\NHibernate\Persister\Entity\AbstractEntityPersister.cs: line 3838
NHibernate.Persister.Entity.AbstractEntityPersister.IsTransient(Object entity, ISessionImplementor session) in d:\CSharp\NH\nhibernate\src\NHibernate\Persister\Entity\AbstractEntityPersister.cs: line 3629
NHibernate.Engine.ForeignKeys.IsTransient(String entityName, Object entity, Nullable`1 assumed, ISessionImplementor session) in d:\CSharp\NH\nhibernate\src\NHibernate\Engine\ForeignKeys.cs: line 193
NHibernate.Engine.ForeignKeys.GetEntityIdentifierIfNotUnsaved(String entityName, Object entity, ISessionImplementor session) in d:\CSharp\NH\nhibernate\src\NHibernate\Engine\ForeignKeys.cs: line 249
NHibernate.Type.ManyToOneType.Disassemble(Object value, ISessionImplementor session, Object owner) in d:\CSharp\NH\nhibernate\src\NHibernate\Type\ManyToOneType.cs: line 137
NHibernate.Cache.StandardQueryCache.Put(QueryKey key, ICacheAssembler[] returnTypes, IList result, Boolean isNaturalKeyLookup, ISessionImplementor session) in d:\CSharp\NH\nhibernate\src\NHibernate\Cache\StandardQueryCache.cs: line 82
NHibernate.Loader.Loader.PutResultInQueryCache(ISessionImplementor session, QueryParameters queryParameters, IType[] resultTypes, IQueryCache queryCache, QueryKey key, IList result) in d:\CSharp\NH\nhibernate\src\NHibernate\Loader\Loader.cs: line 1627
NHibernate.Loader.Loader.ListUsingQueryCache(ISessionImplementor session, QueryParameters queryParameters, ISet`1 querySpaces, IType[] resultTypes) in d:\CSharp\NH\nhibernate\src\NHibernate\Loader\Loader.cs: line 1593
NHibernate.Loader.Loader.List(ISessionImplementor session, QueryParameters queryParameters, ISet`1 querySpaces, IType[] resultTypes) in d:\CSharp\NH\nhibernate\src\NHibernate\Loader\Loader.cs: line 1567
NHibernate.Hql.Ast.ANTLR.Loader.QueryLoader.List(ISessionImplementor session, QueryParameters queryParameters) in d:\CSharp\NH\nhibernate\src\NHibernate\Hql\Ast\ANTLR\Loader\QueryLoader.cs: line 298
NHibernate.Hql.Ast.ANTLR.QueryTranslatorImpl.List(ISessionImplementor session, QueryParameters queryParameters) in d:\CSharp\NH\nhibernate\src\NHibernate\Hql\Ast\ANTLR\QueryTranslatorImpl.cs: line 110
NHibernate.Engine.Query.HQLQueryPlan.PerformList(QueryParameters queryParameters, ISessionImplementor session, IList results) in d:\CSharp\NH\nhibernate\src\NHibernate\Engine\Query\HQLQueryPlan.cs: line 105
NHibernate.Impl.SessionImpl.List(IQueryExpression queryExpression, QueryParameters queryParameters, IList results) in d:\CSharp\NH\nhibernate\src\NHibernate\Impl\SessionImpl.cs: line 679
NHibernate.Impl.SessionImpl.List(IQueryExpression queryExpression, QueryParameters parameters) in d:\CSharp\NH\nhibernate\src\NHibernate\Impl\SessionImpl.cs: line 655
NHibernate.Impl.ExpressionQueryImpl.List() in d:\CSharp\NH\nhibernate\src\NHibernate\Impl\ExpressionQueryImpl.cs: line 63
NHibernate.Linq.NhQueryProvider.Execute(Expression expression) in d:\CSharp\NH\nhibernate\src\NHibernate\Linq\NhQueryProvider.cs: line 31
NHibernate.Linq.NhQueryProvider.Execute[TResult](Expression expression) in d:\CSharp\NH\nhibernate\src\NHibernate\Linq\NhQueryProvider.cs: line 55
GetEnumerator()
ctor(IEnumerable`1 collection)
System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
PersistenceLayer.Test.PersistenceServiceTest.FindWithFetchAndCacheableTest() in …..\PersistenceServiceTest.cs: line 345
Thanks,
Eduardo
Hi folks,
Could I get your feedback on this one? Am I missing something?
Thanks,
session.Query<Foo>().Cacheable().Fetch(f => f.Bar).ToList();
--
You received this message because you are subscribed to the Google Groups "nhusers" group.
To post to this group, send email to nhu...@googlegroups.com.
To unsubscribe from this group, send email to nhusers+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.
Hi Diego,
Are you running off of the trunk? Because this still throws that exception with Alpha1:
IList<ParentObject> pos =
session.Query<ParentObject>().Cacheable().Fetch(po => po.ChildObjects).ToList();
Thanks,
Eduardo
Actually, Alpha2 is also throwing for me. I’m attaching the new stack trace so you can verify that I’m using Alpha2 (the line numbers for the stack vary slightly, reflecting what has been committed to the trunk since Alpha1).
I’ve also updated my little test, just to check if the fact that you are not eagerly fetching a collection, but just a single object, ‘Bar’:
session.Query<Foo>().Cacheable().Fetch(f => f.Bar).ToList();
could be what’s causing this, but unfortunately the result is the same for me:
// this line is ok
IList<ParentObject> pos2 = session.Query<ParentObject>().Cacheable().ToList();
// this line is ok
IList<ChildObject> cos2 = session.Query<ChildObject>().Cacheable().ToList();
// this throws with Alpha2
IList<ChildObject> cos = session.Query<ChildObject>()
.Cacheable()
.Fetch(co => co.Parent).ToList();
// this throws with Alpha2
IList<ParentObject> pos = session.Query<ParentObject>()
.Cacheable()
.Fetch(po => po.ChildObjects).ToList();
I did see the behavior you describe, ‘don't see it caching the query’, but only briefly, just before rebuilding the whole project. (I’m using memcached, and since there is no NHContrib for Alpha2 yet, after a rebuild I started getting errors regarding not being able to load 3.0.0.1001, so I removed the reference and started using HashtableCache instead).
So, I’m wondering if maybe this is what happened for you as well. Could you confirm?
Eduardo
Stack trace:
---------------
System.Reflection.RuntimeMethodInfo.CheckConsistency(Object target)
System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
System.Reflection.RuntimePropertyInfo.GetValue(Object obj, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture)
System.Reflection.RuntimePropertyInfo.GetValue(Object obj, Object[] index)
NHibernate.Properties.BasicPropertyAccessor.BasicGetter.Get(Object target) in d:\CSharp\NH\nhibernate\src\NHibernate\Properties\BasicPropertyAccessor.cs: line 207
NHibernate.Properties.BasicPropertyAccessor.BasicGetter.Get(Object target) in d:\CSharp\NH\nhibernate\src\NHibernate\Properties\BasicPropertyAccessor.cs: line 211
NHibernate.Tuple.Entity.AbstractEntityTuplizer.GetIdentifier(Object entity) in d:\CSharp\NH\nhibernate\src\NHibernate\Tuple\Entity\AbstractEntityTuplizer.cs: line 139
NHibernate.Persister.Entity.AbstractEntityPersister.GetIdentifier(Object obj, EntityMode entityMode) in d:\CSharp\NH\nhibernate\src\NHibernate\Persister\Entity\AbstractEntityPersister.cs: line 3841
NHibernate.Persister.Entity.AbstractEntityPersister.IsTransient(Object entity, ISessionImplementor session) in d:\CSharp\NH\nhibernate\src\NHibernate\Persister\Entity\AbstractEntityPersister.cs: line 3632
NHibernate.Engine.ForeignKeys.IsTransient(String entityName, Object entity, Nullable`1 assumed, ISessionImplementor session) in d:\CSharp\NH\nhibernate\src\NHibernate\Engine\ForeignKeys.cs: line 193
NHibernate.Engine.ForeignKeys.GetEntityIdentifierIfNotUnsaved(String entityName, Object entity, ISessionImplementor session) in d:\CSharp\NH\nhibernate\src\NHibernate\Engine\ForeignKeys.cs: line 249
NHibernate.Type.ManyToOneType.Disassemble(Object value, ISessionImplementor session, Object owner) in d:\CSharp\NH\nhibernate\src\NHibernate\Type\ManyToOneType.cs: line 137
NHibernate.Cache.StandardQueryCache.Put(QueryKey key, ICacheAssembler[] returnTypes, IList result, Boolean isNaturalKeyLookup, ISessionImplementor session) in d:\CSharp\NH\nhibernate\src\NHibernate\Cache\StandardQueryCache.cs: line 82
NHibernate.Loader.Loader.PutResultInQueryCache(ISessionImplementor session, QueryParameters queryParameters, IType[] resultTypes, IQueryCache queryCache, QueryKey key, IList result) in d:\CSharp\NH\nhibernate\src\NHibernate\Loader\Loader.cs: line 1634
NHibernate.Loader.Loader.ListUsingQueryCache(ISessionImplementor session, QueryParameters queryParameters, ISet`1 querySpaces, IType[] resultTypes) in d:\CSharp\NH\nhibernate\src\NHibernate\Loader\Loader.cs: line 1600
NHibernate.Loader.Loader.List(ISessionImplementor session, QueryParameters queryParameters, ISet`1 querySpaces, IType[] resultTypes) in d:\CSharp\NH\nhibernate\src\NHibernate\Loader\Loader.cs: line 1574
NHibernate.Hql.Ast.ANTLR.Loader.QueryLoader.List(ISessionImplementor session, QueryParameters queryParameters) in d:\CSharp\NH\nhibernate\src\NHibernate\Hql\Ast\ANTLR\Loader\QueryLoader.cs: line 298
NHibernate.Hql.Ast.ANTLR.QueryTranslatorImpl.List(ISessionImplementor session, QueryParameters queryParameters) in d:\CSharp\NH\nhibernate\src\NHibernate\Hql\Ast\ANTLR\QueryTranslatorImpl.cs: line 110
NHibernate.Engine.Query.HQLQueryPlan.PerformList(QueryParameters queryParameters, ISessionImplementor session, IList results) in d:\CSharp\NH\nhibernate\src\NHibernate\Engine\Query\HQLQueryPlan.cs: line 105
NHibernate.Impl.SessionImpl.List(IQueryExpression queryExpression, QueryParameters queryParameters, IList results) in d:\CSharp\NH\nhibernate\src\NHibernate\Impl\SessionImpl.cs: line 679
NHibernate.Impl.SessionImpl.List(IQueryExpression queryExpression, QueryParameters parameters) in d:\CSharp\NH\nhibernate\src\NHibernate\Impl\SessionImpl.cs: line 655
NHibernate.Impl.ExpressionQueryImpl.List() in d:\CSharp\NH\nhibernate\src\NHibernate\Impl\ExpressionQueryImpl.cs: line 63
NHibernate.Linq.NhQueryProvider.Execute(Expression expression) in d:\CSharp\NH\nhibernate\src\NHibernate\Linq\NhQueryProvider.cs: line 31
NHibernate.Linq.NhQueryProvider.Execute[TResult](Expression expression) in d:\CSharp\NH\nhibernate\src\NHibernate\Linq\NhQueryProvider.cs: line 55
GetEnumerator()
ctor(IEnumerable`1 collection)
System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
PersistenceLayer.Test.PersistenceServiceTest.FindWithFetchAndCacheableTest() in ….\PersistenceServiceTest.cs: line 366
Care to share your solution? I can’t seem to find the difference between your environment and mine, and still doesn’t work for me.
public class Foo : Entity<Guid>Mapping (by ConfORM):
{
public virtual ICollection<Bar> Bars { get; set; }
}
public class Bar : Entity<Guid>
{
public virtual Foo Foo { get; set; }
}
var config = new Configuration()
.DataBaseIntegration(db =>
{
db.ConnectionProvider<DriverConnectionProvider>();
db.Driver<SqlClientDriver>();
db.ConnectionString =
"Data Source=.;Initial Catalog=test;Integrated Security=True";
db.Dialect<MsSql2008Dialect>();
db.LogSqlInConsole = true;
db.LogFormatedSql = true;
db.HqlToSqlSubstitutions = "true 1, false 0";
})
.Cache(ccp =>
{
ccp.DefaultExpiration = 60;
ccp.Provider<HashtableCacheProvider>();
})
.Proxy(p => p.ProxyFactoryFactory<ProxyFactoryFactory>());
config.SetProperty(Environment.UseQueryCache, "true");
session.Query<Foo>().Cacheable().ToList();
session.Query<Bar>().Cacheable().ToList();
session.Query<Foo>().Cacheable().Fetch(x => x.Bars).ToList();
session.Query<Bar>().Cacheable().Fetch(x => x.Foo).ToList();
Weird, this example throws the same exception for me (attached at the end). There were a few minor things that I had to add/change:
Classes (had to add Entity):
public class Entity<T>
{
public virtual T Id { get; set; }
}
Mapping (had to add namespace,assembly):
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" auto-import="true"
namespace="CacheableFetchTest" assembly="CacheableFetchTest">
Configuration (tried two):
db.Driver<SqlClientDriver>();
db.ConnectionString = "Data Source=xyz;Initial Catalog=abc;Integrated Security=True";
db.Dialect<MsSql2005Dialect>();
//db.Driver<SqlServerCeDriver>();
//db.ConnectionString = "Data Source=DataModel.sdf";
//db.Dialect<MsSqlCeDialect>();
Query:
[TestMethod]
public void TestMethod1()
{
using(ISession session = sessionFactory.OpenSession())
using (ITransaction transaction = session.BeginTransaction())
{
IList<Foo> foos1 = session.Query<Foo>().Cacheable().ToList();
IList<Bar> bars1 = session.Query<Bar>().Cacheable().ToList();
IList<Foo> foos2 = session.Query<Foo>().Cacheable().Fetch(x => x.Bars).ToList();
IList<Bar> bars2 = session.Query<Bar>().Cacheable().Fetch(x => x.Foo).ToList();
}
}
I’m using ‘Mappings.hbm.xml’ as my mapping file, packaged as ‘Embedded Resource’
Given that we are running almost the same code at this point, I guess the only things left to compare are:
(Unfortunately I can’t email attachments out from this account, otherwise I would be sending you the solution. Maybe over the weekend, if you are around/interested. At this point it can’t hurt to start trying this on other systems)
Tables:
/****** Object: Table [dbo].[Foo] Script Date: 08/20/2010 16:57:04 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Foo](
[Id] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
CONSTRAINT [PK_Foo] PRIMARY KEY CLUSTERED
(
[Id] ASC
) ON [PRIMARY]
) ON [PRIMARY]
/****** Object: Table [dbo].[Bar] Script Date: 08/20/2010 16:57:15 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Bar](
[Id] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[Foo] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
CONSTRAINT [PK_Bar] PRIMARY KEY CLUSTERED
(
[Id] ASC
) ON [PRIMARY]
) ON [PRIMARY]
GO
USE [CoreFramework]
GO
ALTER TABLE [dbo].[Bar] WITH CHECK ADD CONSTRAINT [FK_Bar_Foo] FOREIGN KEY([Foo])
REFERENCES [dbo].[Foo] ([Id])
Usings:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NHibernate;
using NHibernate.ByteCode.Castle;
using NHibernate.Cache;
using NHibernate.Cfg;
using NHibernate.Cfg.Loquacious;
using NHibernate.Connection;
using NHibernate.Dialect;
using NHibernate.Driver;
using NHibernate.Linq;
and Libraries:
-Antlr3.Runtime (3.1.3.42154)
-Castle.Core (1.2.0.0)
-Castle.DynamixProxy2 (2.2.0.0)
-Iesi.Collections (1.0.1.0)
-Microsoft.VisualStudio.QualityTools.UnitTestFramework (9.0.0.0)
-NHibernate (3.0.0.1002)
-NHibernate.ByteCode.Castle (3.0.0.1002)
-Remotion.Data.Linq (1.13.41.2)
-System (2.0.0.0)
-System.Core (3.5.0.0)
-System.Data.SqlServerCe (3.5.1.0)
The exception with these objects is:
Test method CacheableFetchTest.UnitTest1.TestMethod1 threw exception: NHibernate.PropertyAccessException: Exception occurred getter of CacheableFetchTest.Entity`1[[System.Guid, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].Id ---> System.Reflection.TargetException: Object does not match target type..
System.Reflection.RuntimeMethodInfo.CheckConsistency(Object target)
System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
System.Reflection.RuntimePropertyInfo.GetValue(Object obj, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture)
System.Reflection.RuntimePropertyInfo.GetValue(Object obj, Object[] index)
NHibernate.Properties.BasicPropertyAccessor.BasicGetter.Get(Object target) in d:\CSharp\NH\nhibernate\src\NHibernate\Properties\BasicPropertyAccessor.cs: line 207
NHibernate.Properties.BasicPropertyAccessor.BasicGetter.Get(Object target) in d:\CSharp\NH\nhibernate\src\NHibernate\Properties\BasicPropertyAccessor.cs: line 211
NHibernate.Tuple.Entity.AbstractEntityTuplizer.GetIdentifier(Object entity) in d:\CSharp\NH\nhibernate\src\NHibernate\Tuple\Entity\AbstractEntityTuplizer.cs: line 139
NHibernate.Persister.Entity.AbstractEntityPersister.GetIdentifier(Object obj, EntityMode entityMode) in d:\CSharp\NH\nhibernate\src\NHibernate\Persister\Entity\AbstractEntityPersister.cs: line 3841
NHibernate.Persister.Entity.AbstractEntityPersister.IsTransient(Object entity, ISessionImplementor session) in d:\CSharp\NH\nhibernate\src\NHibernate\Persister\Entity\AbstractEntityPersister.cs: line 3632
NHibernate.Engine.ForeignKeys.IsTransient(String entityName, Object entity, Nullable`1 assumed, ISessionImplementor session) in d:\CSharp\NH\nhibernate\src\NHibernate\Engine\ForeignKeys.cs: line 193
NHibernate.Engine.ForeignKeys.GetEntityIdentifierIfNotUnsaved(String entityName, Object entity, ISessionImplementor session) in d:\CSharp\NH\nhibernate\src\NHibernate\Engine\ForeignKeys.cs: line 249
NHibernate.Type.ManyToOneType.Disassemble(Object value, ISessionImplementor session, Object owner) in d:\CSharp\NH\nhibernate\src\NHibernate\Type\ManyToOneType.cs: line 137
NHibernate.Cache.StandardQueryCache.Put(QueryKey key, ICacheAssembler[] returnTypes, IList result, Boolean isNaturalKeyLookup, ISessionImplementor session) in d:\CSharp\NH\nhibernate\src\NHibernate\Cache\StandardQueryCache.cs: line 82
NHibernate.Loader.Loader.PutResultInQueryCache(ISessionImplementor session, QueryParameters queryParameters, IType[] resultTypes, IQueryCache queryCache, QueryKey key, IList result) in d:\CSharp\NH\nhibernate\src\NHibernate\Loader\Loader.cs: line 1634
NHibernate.Loader.Loader.ListUsingQueryCache(ISessionImplementor session, QueryParameters queryParameters, ISet`1 querySpaces, IType[] resultTypes) in d:\CSharp\NH\nhibernate\src\NHibernate\Loader\Loader.cs: line 1600
NHibernate.Loader.Loader.List(ISessionImplementor session, QueryParameters queryParameters, ISet`1 querySpaces, IType[] resultTypes) in d:\CSharp\NH\nhibernate\src\NHibernate\Loader\Loader.cs: line 1574
NHibernate.Hql.Ast.ANTLR.Loader.QueryLoader.List(ISessionImplementor session, QueryParameters queryParameters) in d:\CSharp\NH\nhibernate\src\NHibernate\Hql\Ast\ANTLR\Loader\QueryLoader.cs: line 298
NHibernate.Hql.Ast.ANTLR.QueryTranslatorImpl.List(ISessionImplementor session, QueryParameters queryParameters) in d:\CSharp\NH\nhibernate\src\NHibernate\Hql\Ast\ANTLR\QueryTranslatorImpl.cs: line 110
NHibernate.Engine.Query.HQLQueryPlan.PerformList(QueryParameters queryParameters, ISessionImplementor session, IList results) in d:\CSharp\NH\nhibernate\src\NHibernate\Engine\Query\HQLQueryPlan.cs: line 105
NHibernate.Impl.SessionImpl.List(IQueryExpression queryExpression, QueryParameters queryParameters, IList results) in d:\CSharp\NH\nhibernate\src\NHibernate\Impl\SessionImpl.cs: line 679
NHibernate.Impl.SessionImpl.List(IQueryExpression queryExpression, QueryParameters parameters) in d:\CSharp\NH\nhibernate\src\NHibernate\Impl\SessionImpl.cs: line 655
NHibernate.Impl.ExpressionQueryImpl.List() in d:\CSharp\NH\nhibernate\src\NHibernate\Impl\ExpressionQueryImpl.cs: line 63
NHibernate.Linq.NhQueryProvider.Execute(Expression expression) in d:\CSharp\NH\nhibernate\src\NHibernate\Linq\NhQueryProvider.cs: line 31
NHibernate.Linq.NhQueryProvider.Execute[TResult](Expression expression) in d:\CSharp\NH\nhibernate\src\NHibernate\Linq\NhQueryProvider.cs: line 55
GetEnumerator()
ctor(IEnumerable`1 collection)
System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
CacheableFetchTest.UnitTest1.TestMethod1() in …\CacheableFetchTest\CacheableFetchTest\UnitTest1.cs: line 92
Thanks,
Eduardo
From: nhu...@googlegroups.com
[mailto:nhu...@googlegroups.com] On Behalf Of Diego Mijelshon
Sent: Friday, August 20, 2010 2:55 PM
To: nhu...@googlegroups.com
Subject: Re: [nhusers] RE: .Cacheable().Fetch() throws 'Exception
occurred getter of xxx'
Sure
--
Hi Diego,
Hope you had a nice weekend.
I tried the fix you mentioned, but the results are still the same. And come to think about it, it makes sense since I started this exercise using integers as identifiers.
Remember that the problem is not comparing the identifiers themselves, but that the line that takes the object from the array:
else if (!hasTransform)
{
return row.Length == 1 ? row[0] : row; <-- the object is not extracted from the array, because of the lambda
}
Is not being executed.
Thoughts?
Hah, yeah, I thought you might go that route.
Diego, thanks for your responses anyway. I do appreciate the time you put into this.
I’m reaching out to the whole community now: It works for him, it doesn’t work for me. Are there any volunteers willing to give this a try? It shouldn’t take more than 10 minutes to launch Visual Studio and create a solution with all the files already included in this thread.
Thanks in advance,
I thought I would share my findings: Two of my coworkers are getting the same exception.
I don’t think there is a test case that combines both Cacheable() and Fetch(), is it? I’m looking at NHibernate.Test.Linq.EagerLoadTests and NHibernate.Test.Linq.QueryCacheableTests
Would it help if I write a couple of unit test and send them as a patch?
Thanks,
Eduardo
From: Segura, Eduardo [Tech]
Sent: Monday, August 23, 2010 11:19 AM
To: 'nhu...@googlegroups.com'
Subject: RE: [nhusers] RE: .Cacheable().Fetch() throws 'Exception
occurred getter of xxx'
Hah, yeah, I thought you might go that route.
Diego, thanks for your responses anyway. I do appreciate the time you put into this.
I’m reaching out to the whole community now: It works for him, it doesn’t work for me. Are there any volunteers willing to give this a try? It shouldn’t take more than 10 minutes to launch Visual Studio and create a solution with all the files already included in this thread.
Thanks in advance,
Sent: Monday, August 23, 2010 10:36 AM
Sorry to hear you are running into the same problem, although it's good to have confirmation. I created a JIRA issue and attached the VS solution to it.
http://216.121.112.228/browse/NHLQ-75
Thanks,
Eduardo
Hi Eduardo,
Cheers,
Dean
--