Hi Tadeus,
Tadas Garsva wrote:
Hi,
It seems to me that inCririteria is ignored if I use it in query to get
number of elements. For example:
Query q=QueryFactory.newQuery(clazz,criteria,true);
int n=getBroker().getCount(q);
where criteria has a inCriteria
Because of failing details how your inCriteria look like I setup a
complex test with an inCriteria to reproduce your problem.
I use the latest version of OJB from SVN (OJB_1_0_RELEASE branch!).
Class Project and Person use a m:n relation:
Criteria crit_in = new Criteria().addLike("firstname", "tom")
.addOrCriteria(new Criteria().addLike("firstname", "john"));
Query in_query = QueryFactory.newReportQuery(Person.class, new
String[]{"id"}, crit_in, true);
Criteria crit = new Criteria().addLike("title",
name).addIn("persons.id", in_query);
QueryByCriteria q = QueryFactory.newQuery(Project.class, crit);
int count = broker.getCount(q);
The generated sql:
SELECT count(*) FROM PROJECT A0 INNER JOIN PERSON_PROJECT A1 ON
A0.ID=A1.PROJECT_ID INNER JOIN PERSON A2 ON A1.PERSON_ID=A2.ID WHERE
(A0.TITLE LIKE '_testCountWithInCriteria_1178384142125_') AND A2.ID IN
(SELECT DISTINCT B0.ID FROM PERSON B0 WHERE B0.FIRSTNAME LIKE 'tom' OR
(B0.FIRSTNAME LIKE 'john'))
This works for me! So if possible please try the SVN version.
regards,
Armin
Best regards,
Tadeus Garsva
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]