Hibernate version: 3.0
Hello everyone,
I have the following query:
Code:
Query select = session.createQuery("from Produto p, Indice i " +
"where p.dataExclusao is null " +
" and tipo = 1 or tipo = null " +
" and publicar='T' " +
" and i.produto.produto = p.produto " +
" and i.tipoVenda.tipoVenda = ? " +
" order by p.produto");
And I'm receiving the following error:
Code:
java.lang.RuntimeException: org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [auge.bean.Produto#9013]
The reason why it happens is obvious: some rows in Indice have no corresponding in Produto. I can't use a "not-found=ignore" because it's part of the ID. Here goes the mapping:
Code:
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="auge.bean.Indice" table="INDICES" >
<composite-id>
<key-many-to-one name="tipoVenda" column="tipoVenda" class="auge.bean.TipoVenda"
lazy="false"/>
<key-many-to-one name="produto" column="produto" class="auge.bean.Produto"
lazy="false"/>
</composite-id>
<property name="preco" column="preco" type="java.lang.Float" />
</class>
</hibernate-mapping>
The thing is that I don't have and I won't have corresponding rows for each row, and that's just the way I need it. How do I do to get only the rows that have corresponding rows in the other class, avoiding the error?
My second question is: knowing that I am selecting not one, but two sets of objects in a list, how will I (in my Java and JSTL code) access each of them? How do I separate them?
Thank you very much