batmat wrote:
Add the right setFetchMode("yourRelation",FetchMode.JOIN) on your criteria.
I tried:
Code:
Criteria criteria = getSession().createCriteria(Terceiro.Tipo.class)
.setProjection(Projections.projectionList().add(
Projections.property("terceiro")))
.setMaxResults(Properties.maxRecords)
.setFetchMode("Terceiro", FetchMode.JOIN)
;
and:
Code:
Criteria criteria = getSession().createCriteria(Terceiro.Tipo.class)
.setProjection(Projections.projectionList().add(
Projections.property("terceiro")))
.setMaxResults(Properties.maxRecords)
.createCriteria("terceiro", Criteria.INNER_JOIN)
.setFetchMode("terceiro", FetchMode.JOIN)
;
And it do:
select * from ( select this_.ter_codigo as y0_ from terceiros_tipos this_ inner join terceiros terceiro1_ on this_.ter_codigo=terceiro1_.codigo ) where rownum <= ?
select terceiro0_.codigo as codigo6_0_, terceiro0_.nome as nome6_0_, terceiro0_.email as email6_0_, terceiro0_.nome_fantasia as nome4_6_0_ from terceiros terceiro0_ where terceiro0_.codigo=?
I'm using Oracle.
Any other tip?
Thanks,
Adriano