Hi Eduardo,

I'm seeing the same problem here. It's definitely related to it
returning an object[1] instead of the actual entity as you've stated.
My unit test looks identical to yours - do you want to put it in JIRA
or will I?

Cheers,

Dean

On Aug 24, 11:16 pm, "Segura, Eduardo [Tech]" <[email protected]>
wrote:
> 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: '[email protected]'
> 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,
> Eduardo
>
> From: [email protected] [mailto:[email protected]] On Behalf Of 
> Diego Mijelshon
> Sent: Monday, August 23, 2010 10:36 AM
> To: [email protected]
> Subject: Re: [nhusers] RE: .Cacheable().Fetch() throws 'Exception occurred 
> getter of xxx'
>
> No idea... I'm not even looking at the source... it "just works" for me :-)
>
>     Diego
> On Mon, Aug 23, 2010 at 11:22, Segura, Eduardo [Tech] 
> <[email protected]<mailto:[email protected]>> wrote:
> 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?
> Eduardo
>
> From: [email protected]<mailto:[email protected]> 
> [mailto:[email protected]<mailto:[email protected]>] On Behalf 
> Of Diego Mijelshon
> Sent: Friday, August 20, 2010 8:14 PM
>
> To: [email protected]<mailto:[email protected]>
> Subject: Re: [nhusers] RE: .Cacheable().Fetch() throws 'Exception occurred 
> getter of xxx'
>
> Heh, sorry about the missing Entity<T>.
> The only big mistake I see is that you are creating the IDs as Varchar, when 
> they are Guids (uniqueidentifier), which is causing that error.
>
>     Diego
> On Fri, Aug 20, 2010 at 18:14, Segura, Eduardo [Tech] 
> <[email protected]<mailto:[email protected]>> wrote:
> 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\AbstractEntityPersi 
> ster.cs: line 3841
> NHibernate.Persister.Entity.AbstractEntityPersister.IsTransient(Object 
> entity, ISessionImplementor session) in 
> d:\CSharp\NH\nhibernate\src\NHibernate\Persister\Entity\AbstractEntityPersi 
> ster.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 ...
>
> read more »

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to