-->
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: create criteria with component field (Agregate)
PostPosted: Thu Dec 28, 2006 12:28 pm 
Newbie

Joined: Thu Dec 28, 2006 11:53 am
Posts: 1
I try use criteria to search with component field. example

class House
public class House {

private int id;

private String ower;

private Adress adress;

getter....
setter.....
}
class Adress
public class Adress{
private String street;
private String city;
}

My House table
SCM_HOUSE
ID int
OWER varchar2(50)
STREET varchar2(50)
CITY varchar2(30)


House.hbm.xml
<hibernate-mapping>
<class name="com.scm.model.House" table="SCM_HOUSE" schema="SCM">
<id name="id" type="long">
<column name="ID_HOUSE" precision="22" scale="0" />
<generator class="increment"/>
</id>

<component name="adress" class="com.scm.model.Adress">
<property name="street">
<column name="STREET />
</property>
<property name="city">
<column name="CITY" />
</property>
</component>

<property name="ower">
<column name="OWER" />
</property>
</class>
</hibernate-mapping>

when I try do this:

session = getHibernateTemplate().getSessionFactory().openSession();
Criteria criteria = session.createCriteria(clazz);
criteria.add(Expression.eq("ower", "paul"));

Criteria criteriaAdress = criteria.createCriteria("adress");
criteriaAdress.add(Expression.eq("city", "alabama"));
Collection result = criteria.list();

I get this error: could not resolve property: city of: com.scm.modelo.House.
but if I am not use component field, if a use a
relationship one to one or some other, I get sucess in my operation.so this problem occurs only if I use a component field (agregate) in my class.

some body knows how can I resolve this problem???


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 09, 2008 9:22 am 
Beginner
Beginner

Joined: Mon Feb 04, 2008 1:48 pm
Posts: 30
Did you ever resolve this? I have the same issue.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 19, 2009 3:34 am 
Newbie

Joined: Fri May 13, 2005 2:47 am
Posts: 5
instead of
Code:
Criteria criteriaAdress = criteria.createCriteria("adress");
criteriaAdress.add(Expression.eq("city", "alabama"));


try

Code:
criteria.add(Expression.eq("adress.city", "alabama"));


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.