Hibernate: How to query to an object which it's collection proprty contains a specific value?
I've got a Player
Object in which there is a Collection<Stock>
. I'm willing to write a hibernate query which returns the list of playe开发者_运维百科rs who have a specific stock (for example stock.symbol="**").
any ideas?
No problem use HQL with join syntax.
see it here
http://docs.jboss.org/hibernate/core/3.6/reference/en-US/html/queryhql.html#queryhql-joins-forms
For example:
Player p join p.myStocks stock where stock.symbol = :symbol
精彩评论