How to make query on a property from a joined table in Hibernate using Criteria
Posted
by Palo
on Stack Overflow
See other posts from Stack Overflow
or by Palo
Published on 2010-03-16T10:22:22Z
Indexed on
2010/03/16
10:26 UTC
Read the original article
Hit count: 264
Hello,
I have the following mapping:
<hibernate-mapping package="server.modules.stats.data">
<class name="User" table="user">
<id name="id">
<generator class="native"></generator>
</id>
<many-to-one name="address" column="addressId" unique="true" lazy="false" />
</class>
<class name="Address" table="address">
<id name="id">
<generator class="native"></generator>
</id>
<property name="street" />
</class>
</hibernate-mapping>
How can I do a Criteria query to select all users living on some street?
That is create Criteria query for this SQL:
Select * from user join address on user.addressId = address.id where address.street='someStreet'
© Stack Overflow or respective owner