aspose file tools*
The moose likes Object Relational Mapping and the fly likes Hibernate criteria in many-to-one mapping. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate criteria in many-to-one mapping." Watch "Hibernate criteria in many-to-one mapping." New topic
Author

Hibernate criteria in many-to-one mapping.

harshad kadam
Greenhorn

Joined: Mar 19, 2011
Posts: 8
I am using criteria to select some records from DB with restrictions on it. I have one table say A & its pojo A.java, its field mapped with other table B. (many-to-one).
When i use criteria with restriction, the id (which is the primary key of ) of other class is mapped in the property field. But when i give some other variable from B.java, it gives "could not resolve property" excepion.
Why this happens?

here is the code:



harshad kadam
Greenhorn

Joined: Mar 19, 2011
Posts: 8
the properties "updatedUserId.officerName" & "logSheet.status" are not being resolved!
Hemant Thard
Ranch Hand

Joined: Dec 23, 2008
Posts: 122
hi harshad ,

try using this :

Hemant Thard
Ranch Hand

Joined: Dec 23, 2008
Posts: 122
Hi harshad ,

try using alias.

here's an example
Hemant Thard
Ranch Hand

Joined: Dec 23, 2008
Posts: 122
here's another way

 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Hibernate criteria in many-to-one mapping.