java - QueryDsl: Select count of rows that meets the criteria -
i have 2 records in db. this:
qloginregistryentry loginregistryentry = qloginregistryentry.loginregistryentry; jpaquery query = new jpaquery(jpa.em()); list<loginregistryentry> result; result = query.from(loginregistryentry) .where(loginregistryentry.indate.startswith(yearandmonth)) .list(loginregistryentry); system.out.println(result.size()); it return 2, correct
when this:
qloginregistryentry loginregistryentry2 = new qloginregistryentry("a"); long count = query.from(loginregistryentry2).count(); system.out.println(count); it return 4, wrong
what doing wrong? how should download count of rows meets criteria?
i don't think executed queries in isolation. reused query object first query , continued, got cross join , got 2 * 2 = 4 results.
Comments
Post a Comment