-->
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.  [ 1 post ] 
Author Message
 Post subject: Criteria: createCriteria with Component
PostPosted: Tue Dec 04, 2007 10:53 am 
Newbie

Joined: Tue Dec 04, 2007 10:20 am
Posts: 13
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3.2

Mapping documents:

Code between sessionFactory.openSession() and session.close():

Criteria crit=session.createCriteria(MOS.class).createAlias("name", "uno");

System.out.println(crit); // The result of this print is: CriteriaImpl(ims.core.resource.people.domain.objects.MemberOfStaff:this[Subcriteria(uno:name)][])


if (filter.getNameIsNotNull() && filter.getName().getSurname() != null && filter.getName().getSurname().length() > 0)
{
//crit.add(Restrictions.like("uno.surname",filter.getName().getSurname().toUpperCase()));
//Here is when the exception occurs

Full stack trace of any exception that occurs:


org.hibernate.QueryException: could not resolve property: uno of: ims.core.resource.people.domain.objects.MemberOfStaff
at org.hibernate.persister.entity.AbstractPropertyMapping.throwPropertyException(AbstractPropertyMapping.java:43)
at org.hibernate.persister.entity.AbstractPropertyMapping.toType(AbstractPropertyMapping.java:37)
at org.hibernate.persister.entity.AbstractEntityPersister.toType(AbstractEntityPersister.java:1312)



Name and version of the database you are using:

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


The fact is that the name attribute is an component object type. When I try to do this same query with another kind of object I get what I want, but with a component object I can't get it to work. I've read in the "Java Persistence with Hibernate" book this: "Hibernate fails with an exception and tells you that the property you want to alias doesn't represent an entity association when you work with a collection of components".

My question is, is there any way to do this join with Criteria in newer versions of Hibernate? Or is there any way to do it with hibernate 3.2?

Thank you very much in advance


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

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.