One of my pojo (called Contract) contains a List, called DocumentList which contains a pojo called ContractDocument.
This list has been mapped like this: (xdoclet code)
Code:
/**
* @hibernate.bag
* inverse="true"
* lazy="false"
* cascade="all-delete-orphan"
* @hibernate.collection-key
* column="ID_CONTRACT"
* @hibernate.collection-one-to-many
* class="com.synos.egov.licitacao.pojo.ContractDocument"
*/
Contract also has an number field, that tells me what is the number of the contract. My doubt is, what is the hql I need that will give me back that list, when I have the number of Contract? I have tried this but it doesn't work:
Code:
String search = "select con.DocumentList " +
"from " +
"Contract con, " +
"where " +
"con.id = :contract ";
Query query = sess.createQuery(busca);
query.setInteger("contract", Integer.parseInt(number));
List documents = query.list();