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