Hi list!
I'm new here in the mailing list. I have a <any> association between 2 legacy tables:
Code:
<any id-type="int" meta-type="int" name="maquina" >
<meta-value class="br.com.simula.domain.maquina.impl.MaquinaPapelImpl" value="1"/>
<meta-value class="br.com.simula.domain.maquina.impl.RebobinadeiraImpl" value="2"/>
<meta-value class="br.com.simula.domain.maquina.impl.CalandraImpl" value="3"/>
<meta-value class="br.com.simula.domain.maquina.impl.CoaterImpl" value="4"/>
<meta-value class="br.com.simula.domain.maquina.impl.CortadeiraImpl" value="5"/>
<meta-value class="br.com.simula.domain.maquina.impl.RebobinadeiraAuxiliarImpl" value="7"/>
<column name="TMAQ_ID"/>
<column name="MAQ_ID"/>
</any>
And I want to make a JPA query using this association:
Code:
Query q = getEntityManager().createQuery(
"select count(corr) " +
"from Corrida corr " +
"join corr.conjugacoes conjs " +
"join conjs.bobinas bobs " +
"left join corr.cortadeiras corts " +
"join corr.pedidos peds " +
"left join peds.itemPedido.roteiro rots " +
"where conjs.liberada=?1 and bobs.destino = ?2 and (corts.cortadeira = ?3 or rots.maquina = ?3)");
The third parameter is a CortadeiraImpl object, and the rots.maquina is the mapping above. But when I do this, the SQL generated is:
Code:
select count(corrida0_.Corr) as col_0_0_
from Corr corrida0_
inner join Conj conjugacoe1_ on corrida0_.Corr=conjugacoe1_.Corr
inner join BobConj bobinas2_ on conjugacoe1_.Corr=bobinas2_.Corr and conjugacoe1_.Conj=bobinas2_.Conj
left outer join CortCorr cortadeira3_ on corrida0_.Corr=cortadeira3_.Corr
inner join PedCorr pedidos4_ on corrida0_.Corr=pedidos4_.Corr
left outer join Pedidos itempedido5_ on pedidos4_.IDPedido=itempedido5_.IDPedido
left outer join RoteiroPedido roteiro6_ on itempedido5_.IDPedido=roteiro6_.IDPedido
where conjugacoe1_.LiberadaSN='true' and bobinas2_.Destino='c' and (cortadeira3_.IDCortadeira=1 or roteiro6_.TMAQ_ID=1 and roteiro6_.MAQ_ID=null)
As you can see: 'roteiro6_.TMAQ_ID=1 and roteiro6_.MAQ_ID=null' isn't what I expected... Something like 'roteiro6_.TMAQ_ID=5 and roteiro6_.MAQ_ID=1' is what I wanted to see!
I'm using the hibernate entity manager 3.3.2.GA. Any clues? Does the <any /> mapping + polymorphic collection + JPQL work as expected?