Sorry.. I meant to say that I was using 2.1 beta 3.

Which doco ? The doco at
http://www.hibernate.org/hib_docs/reference/html/query-criteria.html

Or is there a 2.1 beta 3 specific set of docs..

DO I need to get them from CVS ? If so which repo ?

Cheers,

Cameron

> -----Original Message-----
> From: Gavin King [mailto:[EMAIL PROTECTED] 
> Sent: Thursday, 2 October 2003 6:30 PM
> To: Cameron Braid
> Cc: [EMAIL PROTECTED]
> Subject: Re: [Hibernate] I need help with the Criteria API 
> when using joins
> 
> 
> You need to be using Hibernate 2.1. It is covered in the doco for 2.1.
> 
> Cameron Braid wrote:
> 
> >I couldn't find any info on this subject on the hibernate 
> site.  There 
> >are examples of simple criteria based queries, but nothing with 
> >relationships.
> >
> >Does anyone have any code that achieves something like this ?
> >Or refrence to anything that shows how ?
> >
> >Is it possible, or is it yet to be implemented ?
> >
> >Thanks
> >
> >Cameron
> >
> >  
> >
> >>-----Original Message-----
> >>From: [EMAIL PROTECTED]
> >>[mailto:[EMAIL PROTECTED] On 
> >>Behalf Of Cameron Braid
> >>Sent: Wednesday, 1 October 2003 10:28 PM
> >>To: [EMAIL PROTECTED]
> >>Subject: RE: [Hibernate] I need help with the Criteria API 
> >>when using joins
> >>
> >>
> >>I forgot to include the exception I was getting
> >>
> >>net.sf.hibernate.QueryException: could not resolve property:
> >>order.state [null]
> >>    at 
> >>net.sf.hibernate.persister.AbstractPropertyMapping.toColumns(A
> >>bstractPro
> >>pertyMapping.java:42)
> >>    at 
> >>net.sf.hibernate.expression.AbstractCriterion.getColumns(Abstr
> >>actCriteri
> >>on.java:35)
> >>    at 
> >>net.sf.hibernate.expression.SimpleExpression.toSqlString(Simpl
> >>eExpressio
> >>n.java:40)
> >>    at
> >>net.sf.hibernate.loader.CriteriaLoader.(CriteriaLoader.java:53)
> >>    at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:3426)
> >>    at
> >>net.sf.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:149)
> >>
> >>    
> >>
> >>>-----Original Message-----
> >>>From: [EMAIL PROTECTED]
> >>>[mailto:[EMAIL PROTECTED] On
> >>>Behalf Of Cameron Braid
> >>>Sent: Wednesday, 1 October 2003 9:28 PM
> >>>To: [EMAIL PROTECTED]
> >>>Subject: [Hibernate] I need help with the Criteria API when 
> >>>using joins
> >>>
> >>>
> >>>I am using Hibernate 2 beta 3.
> >>>
> >>>I can use the criteria api successfully to query properties of the 
> >>>'root' persistent class (OrderItem.class)
> >>>
> >>>Criteria = session.createCriteria(OrderItem.class);
> >>>
> >>>though when I want to query acros a many to one 
> relationship, I can't 
> >>>work out how to do it.
> >>>
> >>>I have an existing text query that I want to convert to 
> allow me to 
> >>>make options optional :
> >>>
> >>>String txt = "from orderItem in class " +
> >>>OrderItem.class.getName() ; String joiner = " where ";
> >>>if (filter.getState() != null) {
> >>>  txt = txt + joiner + " orderItem.order.state = :orderState";
> >>>  joiner = " and ";
> >>>}
> >>>
> >>>... more filter options here ...
> >>>
> >>>Query q = hibernateSession.createQuery(txt);
> >>>
> >>>if (filter.getState() != null) {
> >>>  q.setParameter("orderState", filter.getState());
> >>>}
> >>>
> >>>.. more param bindings here ..
> >>>
> >>>I have tried this :
> >>>
> >>>Criteria criteria =
> >>>      
> >>>
> >>hibernateSession.createCriteria(OrderItem.class);
> >>    
> >>
> >>>if (filter.getState() != null) {
> >>>  criteria.add(Expression.eq("order.state", filter.getState())); }
> >>>
> >>>Which results in an error saying that 'order' ...
> >>>
> >>>I have tried using aliases - though I don't know what I am 
> doing here 
> >>>;)
> >>>  criteria.createAlias("order", "order");
> >>>I have tried using "this.order.state" instead of "order.state"
> >>>
> >>>I have run out of ideas.
> >>>
> >>>Can anyone help ?
> >>>
> >>>Thanks.
> >>>
> >>>Cameron
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>-------------------------------------------------------
> >>>This sf.net email is sponsored by:ThinkGeek
> >>>Welcome to geek heaven.
> >>>http://thinkgeek.com/sf 
> >>>_______________________________________________
> >>>hibernate-devel mailing list [EMAIL PROTECTED]
> >>>https://lists.sourceforge.net/lists/listinfo/hibernate-devel
> >>>
> >>>
> >>>      
> >>>
> >>
> >>
> >>-------------------------------------------------------
> >>This sf.net email is sponsored by:ThinkGeek
> >>Welcome to geek heaven.
> >>http://thinkgeek.com/sf
> >>_______________________________________________
> >>hibernate-devel mailing list [EMAIL PROTECTED]
> >>https://lists.sourceforge.net/lists/listinfo/hibernate-devel
> >>
> >>    
> >>
> >
> >
> >
> >
> >-------------------------------------------------------
> >This sf.net email is sponsored by:ThinkGeek
> >Welcome to geek heaven.
> >http://thinkgeek.com/sf 
> _______________________________________________
> >hibernate-devel mailing list
> >[EMAIL PROTECTED]
> >https://lists.sourceforge.net/lists/listinfo/hibernate-devel
> >  
> >
> 
> 




-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel

Reply via email to