Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jdo count wrong query ? #1015

Closed
hkaito opened this issue Oct 27, 2014 · 0 comments
Closed

jdo count wrong query ? #1015

hkaito opened this issue Oct 27, 2014 · 0 comments
Labels
bug
Milestone

Comments

@hkaito
Copy link

@hkaito hkaito commented Oct 27, 2014

i have an entity like this

class Group {
 Account owner;
 Set<Role> roles = new HashSet<>();
}

class Role {
  Set<Group> groups = new HashSet<>();
}

and, i want to retrieve any role that have relation with group that have specific account as it owner.
my predicate, look like this.

final Predicate p = QRole.role.groups.any().owner.eq(account);
new JDOQuery(pm).from(QRole.role).where(p).count();

it throws an error. ( i'm using datanucleus as jdo provider)

org.datanucleus.exceptions.NucleusUserException: JDOQL query has result clause using aggregate (count) but this needs 1 argument

log the query

2014-10-27 20:15:57,029 DEBUG [ JDOQuery ] SELECT count(this, role_groupsf8afe) FROM org.test.persistence.entity.Role WHERE this.groups.contains(role_groupsf8afe) && role_groupsf8afe.owner == a1 VARIABLES org.test.persistence.entity.Group role_groupsf8afe PARAMETERS org.test.persistence.entity.Account a1

2014-10-27 20:15:57,029 DEBUG [ Query ] JDOQL Single-String with "SELECT count(this, role_groupsf8afe)
FROM org.test.persistence.entity.Role
WHERE this.groups.contains(role_groupsf8afe) && role_groupsf8afe.owner == a1
VARIABLES org.test.persistence.entity.Group role_groupsf8afe
PARAMETERS org.test.persistence.entity.Account a1"

2014-10-27 20:15:57,045 DEBUG [ Query ] JDOQL Query : Compiling "SELECT UNIQUE count(this, role_groupsf8afe) FROM org.test.persistence.entity.Role WHERE this.groups.contains(role_groupsf8afe) && role_groupsf8afe.owner == a1 VARIABLES org.test.persistence.entity.Group role_groupsf8afe PARAMETERS org.test.persistence.entity.Account a1"

2014-10-27 20:15:57,061  INFO [ JDO ] Exception thrown
JDOQL query has result clause using aggregate (count) but this needs 1 argument
org.datanucleus.exceptions.NucleusUserException: JDOQL query has result clause using aggregate (count) but this needs 1 argument

not sure, why count query generate two parameter (count(this, role_groupsf8afe)) instead of one (count(this)), is there something wrong with my predicate or there some issue with querydsl ?

thanks,

@timowest timowest added the bug label Oct 27, 2014
@timowest timowest added this to the 3.5.1 milestone Oct 27, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

2 participants
You can’t perform that action at this time.