KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm having problems with a Hibernate criteria. I'm trying to make a Criteria where I look at the id of a member object of the class the query returns. For example: Criteria crit = session.createCriteria(Enquiry.class); crit.add(Expression.eq("lecture.admin.id", userId));` The result of this is an exception: org.hibernate.QueryException: could not resolve property: lecture.admin.id of: xxx.yyy.Enquiry The Enquiry class does contain the lecture variable, which in turn contains the admin variable. I have tried using lecture.id and that works fine. Is there a limit to the number of levels you can go down the object hierarchy like this? Thanks! Code snippets: public class Lecture extends TransferItem { private User admin; public User getAdmin() { return admin; } } The 'User' class extends the Person class, which in turn extends an Item class, which has the getId() method: public Integer getId() { if (id != null) { return id; } return TransferBean.NOT_SET; } From the Hibernate mapping XML: <class name="User" table="user"> <id column="user_id" name="id"> <generator class="increment"/> </id> ... <class name="Lecture" table="lecture"> <many-to-one class="User" column="user_fk" lazy="false" name="admin"/>` This is the user table: mysql> show columns from user; +-----------------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-----------------+--------------+------+-----+---------+-------+ | user_id | int(11) | NO | PRI | | | | firstname | varchar(50) | YES | | NULL |
Tags (comma-separated)
Save Edits
Cancel