views:

67

answers:

1

Hello, I'm triying to access inside of the properties of an object inside of an criteria query. I have the follows:

    <list name="locationsNatural" schema="public" table="natural$locations" lazy="false">
  <key column="locations_"  />
  <list-index column="locationsindex_" base="1"/>
  <many-to-many
   class="com.idom.dto.estr.Locations"/>
 </list>

inside of Natural class. I'm triying to check if a location is included inside to the locationsNatural list, but I don't know how to. At the moment I have obtained the list of the objects by the following HQL query:

select r.locationsNatural from Natural r where r.id=1

but I prefer to obtained it by Criteria query, at the moment I can access to the object Natural with the id specified but I can't access to locationsNatural because the result that I obtain is < null>.

session.createCriteria(Natural.class).add(Restrictions.eq("id",1")).list();

A: 

At the moment I did the follows, but it's a little far that I want.

String[] listAux = {"MADRID","SEVILLA"}; session.createCriteria(Natural.class). createCriteria("locationsNatural").add(Restrictions.in("name",listAux)). list();

And obtain whose Natural items that contain at least one of the elements of the listAux, but I only want whose items that contain all the items of listAux. Somebody can help me how do it? Thanks in advance.