NHibernate Linq 3 2nd Level Cache and Fetch clause do not work together

137 views
Skip to first unread message

Luis Fernando

unread,
Mar 21, 2011, 7:52:50 AM3/21/11
to nhu...@googlegroups.com
Hello, good morning.

Recently I decided to play with cache in NHibernate 3 and Linq and everything worked fine until I decided to use the Fetch clause and came across a very strange exception, PropertyAccessException, after a lot searching and finding nothing I decided to ask for your help.

Query that works perfectly;

var result = MySession.Query<Company>().Cacheable().ToList();

Query that does NOT work;

var result = MySession.Query<Company>().Cacheable().Fetch(e => e.Employees).ToList();

Output exception: NHibernate.PropertyAccessException: Exception occurred getter of MyProject.Empresa.Id ---> System.Reflection.TargetException: Object does not match target type.

Do not worry about that "Object does not match target type" mapping is correct, the problem really is with the Cache system and Fetch clause.
Thanks for any help.

NHibernate version: 3.1.0

* Translated by Google, from Portuguese.

Luis Fernando

unread,
Mar 21, 2011, 10:03:29 AM3/21/11
to nhu...@googlegroups.com
It seems that it is indeed a Bug http://216.121.112.228/browse/NH-2587

So I ask your help to vote for this bug so it can be solved soon.

Imagine a project already well structured using LinqToNHibernate, but demand was so great that now the optimization
in response time is no longer just an option, now I have to choose between continuing as it is or rewrite all
the data access layer to implement the Cache.

Cristian Eriomenco

unread,
Nov 22, 2014, 2:06:07 PM11/22/14
to nhu...@googlegroups.com
I've got same issue. Did you found a solution?

Ricardo Peres

unread,
Nov 22, 2014, 2:51:40 PM11/22/14
to nhu...@googlegroups.com
According to Jira (https://nhibernate.jira.com/browse/NH-2587), this was fixed a long time ago.
What version of NHibernate are you using?

RP

Cristian Eriomenco

unread,
Nov 23, 2014, 6:33:38 AM11/23/14
to nhu...@googlegroups.com
Hi, I'm using NHibernate version 3.4.0.400 . 

Cu stimă,                                                                                        Eriomenco Cristian
------------------

--
You received this message because you are subscribed to a topic in the Google Groups "nhusers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/nhusers/CqZzGlPS8mE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to nhusers+u...@googlegroups.com.
To post to this group, send email to nhu...@googlegroups.com.
Visit this group at http://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/d/optout.

Ricardo Peres

unread,
Nov 23, 2014, 9:10:09 AM11/23/14
to nhu...@googlegroups.com
Can you report a bug in Jira (nhibernate.jira.com), with a test case (the simplest you can come up with that demonstrates the problem)?

RP

Cristian Eriomenco

unread,
Nov 23, 2014, 1:16:58 PM11/23/14
to nhu...@googlegroups.com
Yes Ricardo, I'll make a sample project and attach it to the ticket. Thank you for your response.

Cu stimă,                                                                                        Eriomenco Cristian
------------------

Cristian Eriomenco

unread,
Nov 24, 2014, 6:52:55 AM11/24/14
to nhu...@googlegroups.com
Hi Ricardo. I've opened a ticket. https://nhibernate.jira.com/browse/IES-3 Unfortunatelly I can't change the right category for the ticket. I've also attached a sample application demonstrating the issue.

Thank you!

Cu stimă,                                                                                        Eriomenco Cristian
------------------

Reply all
Reply to author
Forward
0 new messages