-->
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.  [ 2 posts ] 
Author Message
 Post subject: Hibernate projection for component properties
PostPosted: Fri Dec 12, 2008 8:55 am 
Newbie

Joined: Fri Dec 12, 2008 8:41 am
Posts: 3
Hi, I've tried to use hibernate's criteria query API to execute a query that defines a projection using a component property.
I have
List list = session.createCriteria(Person.class)
.add( Restrictions.like("name", "%a%") )
.list();

where name is an attribute in Person class,This works fine..
But if i use a component , like,

List list1 = session.createCriteria(Employee.class)
.add( Restrictions.like("contactDetails", "%a%") )
.list();

The property used for projection is "contactDetails" of (component) is of type 'EmployeeContactDetails'.
Unfortunately, that does not work - instead, the following exception is thrown:

org.hibernate.QueryException: property does not map to a single column: contactDetails

(Note: Class Employee has a property "contactDetails" of type ''EmployeeContactDetails''. The property 'contactDetails' is mapped as component )

Any Help
Rachel


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

Joined: Fri May 13, 2005 2:47 am
Posts: 5
if "contactDetails" is a component, what sense does following make?
Code:
.add( Restrictions.like("contactDetails", "%a%") )

i am assuming contactDetails is a component which will have one or more properties. So, one should be adding a criteria on one of those properties.
That can be done by
Code:
.add( Restrictions.like("contactDetails.property1", "%a%") )

for property "property1" in contactDetails component.

The exception thrown looks perfectly valid


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.