Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate criteria in many-to-one mapping.

 
harshad kadam
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the properties "updatedUserId.officerName" & "logSheet.status" are not being resolved!
 
Hemant Thard
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi harshad ,

try using this :

 
Hemant Thard
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi harshad ,

try using alias.

here's an example
 
Hemant Thard
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
here's another way

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic