Hi,
I have 2 tables: 1. a master table with single attributes of some objects (id, name, title, ...) 2. a table with repeating attributes (master_id, attribute_name, attribute_value)
Example data for #2: - 10, "authors", "John Bill" - 10, "authors", "Merry J" - 10, "owners", "Chris O." - 11. "authors", "Andrew K."
It's a one-to-many relation: <set name="repeating" table="xxx" cascade="none" mutable="false" lazy="true" fetch="join"> <key column="...."/> <one-to-many class="...." /> </set>
I want to find the master object (id=10) where "authors" = "John Bill" and "authors" = "Merry J" and "owners" = "Chris O."
For the first condition i can do it in that way:
session.createCriteria(Master.class) .createCriteria("repeating") .add(Restrictions.eq("attributeName", "authors")) .add(Restrictions.eq("attributeValue", "John Bill")) .setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY).list();
How can i add other conditions?
Thanks
|