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?
您没有提供太多,但是根据您的要求。这应该可以工作
Query q = sess.createQuery(" select o.owner from animal as o where o.animalId = 5")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.