Reputation: 1967
I have two tables. Property name and column name in brackets.
Table Animal has fields: animalId (animal_id), name (name), owner (owner_id) owner is many to one relationship to owner object and owner_id column
Table Owner has fields: ownerId (owner_id), name
I want to select an the owner of animal who has id 5. How can that be done with hibernate?
Upvotes: 0
Views: 1156
Reputation: 722
You haven't provided much, but from what you're asking for.. this should work
Query q = sess.createQuery(" select o.owner from animal as o where o.animalId = 5")
Upvotes: 2