I have a Session object which has a List of SessionAttribute objects.
The SessionAttribute is mapped as a composite-element.
How can I query all Session objects which have a SessionAttribute whose value property has a specific value?
POJOs
Code:
public class Session
{
private long sessionId;
private List attributes;
private String name;
// + getter/setter
}
Code:
public class SessionAttribute
{
private String name;
private String value;
// + getter/setter
}
Hibernate version: 2.0
Mapping documents:Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping
>
<class
name="de.wowware.hibernatetest.model.beans.Session"
table="SESSION"
>
<id
name="sessionId"
column="session_id"
type="long"
>
<generator class="increment">
</generator>
</id>
<list
name="attributes"
table="SESSION_ATTRIBUTE"
lazy="false"
cascade="none"
>
<key
column="attribute_id"
>
</key>
<index
column="position"
/>
<composite-element
class="de.wowware.hibernatetest.model.beans.SessionAttribute"
>
<property
name="name"
type="java.lang.String"
column="name"
/>
<property
name="value"
type="java.lang.String"
column="value"
/>
</class>
</hibernate-mapping>
Name and version of the database you are using:
MySQL 4.0.15