-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Type mismatch in NHibernate.Criterion.SimpleExpression
PostPosted: Sat May 23, 2009 12:53 pm 
Newbie

Joined: Sat May 23, 2009 12:16 pm
Posts: 2
I have a type named CodeText for some special properties and I create a type named CodeTextUserType implemented IUserType to support my type for hibernate, and my mapping file like this:
<property name="Gender" type="xxx.xxx.CodeTextUserType" />

Everything does well except using Expression:
cri.Add(Expression.Eq("Gender", new CodeText("01")));
I got an exception "Type mismatch in NHibernate.Criterion.SimpleExpression: Gender expected type xxx.xxx..CodeTextType, actual type xxx.CodeText"

I can not change code new CodeText("01") to code new CodeTextUserType("01") because it looks so strange and CodeTextUserType don't have that constructor.

I know that I can make CodeText to implement IUserType instead of CodeTextUserType to resolve this problem, but I just do not want my type to depend on NHibernate. If I do so, my domains project must have the reference to Nhibernate.
so, want shall i do?


Top
 Profile  
 
 Post subject: Re: Type mismatch in NHibernate.Criterion.SimpleExpression
PostPosted: Mon May 25, 2009 3:32 am 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
What does your ReturnedType property looks like ? Afaik it should be

Code:
       public virtual Type ReturnedType
        {
            get { return typeof( CodeText ); }
        }


and your error sounds like you return typeof(CodeTextUserType) there.

_________________
--Wolfgang


Top
 Profile  
 
 Post subject: Re: Type mismatch in NHibernate.Criterion.SimpleExpression
PostPosted: Tue May 26, 2009 3:30 am 
Newbie

Joined: Sat May 23, 2009 12:16 pm
Posts: 2
wolli wrote:
What does your ReturnedType property looks like ? Afaik it should be

Code:
       public virtual Type ReturnedType
        {
            get { return typeof( CodeText ); }
        }


and your error sounds like you return typeof(CodeTextUserType) there.


Thanks for your reply very much, that is the real reason.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.