The criteria api is generating ambiguous column names which prevents setMaxResults from working
this is the pertinent sql that is generated
Code:
select * from (
this.id as id3_,
dealcommen1_.id as id__,
x0_.id as id1_,
x1_.id as id__,
from Deal this left outer join deal_comments dealcommen1_ on this.id=dealcommen1_.deal_id
inner join Company x0_ on this.company_id=x0_.id
inner join Address x1_ on x0_.id=x1_.company_id
where lower(x1_.city) like '%san francisco%' )
where rownum <= 40
As you can see all the joined classes have the same id alias which prevents the select * from working, not sure why it wraps it with select * when just adding and rownum <=40 does the trick too.
Here is the criteria code
Code:
if(!"".equals(dealSearch.getCity()))
{
c.createCriteria("company").createCriteria("addresses").add(Expression.ilike("city", dealSearch.getCity(), MatchMode.ANYWHERE));
}
c.setMaxResults(40);
Any thoughts on how to fix this ? Changing the mapping/busobjects is not the route I want to take. DB is Oracle 9i
Damian