-->
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: problem with criteria parameter
PostPosted: Fri Feb 05, 2010 2:51 pm 
Newbie

Joined: Thu Dec 03, 2009 2:10 pm
Posts: 13
Hello,
I have the following criteria defined -

Code:
return _session.CreateCriteria(typeof(parent))
                .Add(Expression.Eq("parent_field","data"))
                .CreateCriteria("child",NHibernate.SqlCommand.JoinType.LeftOuterJoin)
                    .Add(Expression.IsNull("child_field"))
                .SetMaxResults(25)
                .List<parent>();


When I run this code, I am getting the folowing error -
{"OleDbCommand.Prepare method requires all variable length parameters to have an explicitly set non-zero Size."}

If I remove the second line where I put a parameter on the parent table, it runs fine.
Does anyone have any idea what is happening?


Top
 Profile  
 
 Post subject: Re: problem with criteria parameter
PostPosted: Tue Feb 09, 2010 2:10 pm 
Newbie

Joined: Thu Dec 03, 2009 2:10 pm
Posts: 13
I have been trying and searching different things, but nothing seems to work. I read where someone said to add the column length in my mapping file, but that doesn't seem to work either (or I am doing it incorrectly).
Can someone help with regards to adding the column length in my mapping?

Thanks


Top
 Profile  
 
 Post subject: Re: problem with criteria parameter
PostPosted: Tue Feb 16, 2010 9:37 am 
Newbie

Joined: Thu Dec 03, 2009 2:10 pm
Posts: 13
I was able to solve this by changing the criteria to the following -

Code:
return _session.CreateCriteria(typeof(parent))
                .Add(Expression.Gt("parentField1", DateTime.Now.AddDays(-14)))
                .Add(Expression.Sql("parentField2 = 'parameter'"))
                .Add(Expression.Sql("parentField3 = 'parameter2'"))
                .CreateCriteria("child", NHibernate.SqlCommand.JoinType.LeftOuterJoin)
                    .Add(Expression.IsNull("childField"))
                .SetMaxResults(25)
                .List<parent>();


Hope that might help someone.


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.