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

Replacing SIZE with COUNT produces wrong result when the target entity has a composite id #92

Closed
beikov opened this issue Oct 14, 2014 · 3 comments
Assignees
Milestone

Comments

@beikov
Copy link
Member

beikov commented Oct 14, 2014

Subqueries are not affected, but the transformation which uses group by and count is wrong. This does not seem to be handeled properly and some databases don't support COUNT DISTINCT of a tuple. Therefore we will have to use the CHR or CHAR function to produce an expression like

col1 || CHR(1) || col2 || CHR(1) || ...

Since the character with the ASCII value of 1 will probably not be part of any string and the ASCII value 0 is not allowed, this should do the job.

JPA 2.1 compliant way would be

col1 || FUNCTION('CHR', 1) || col2 || FUNCTION'(CHR', 1) || ...

Databases that support row value constructors or tuples with a syntax like (col1, col2, ...) in count distincts could actually make use of it.

@beikov beikov self-assigned this Oct 14, 2014
@beikov beikov added this to the 1.0.0 milestone Oct 14, 2014
@beikov
Copy link
Member Author

beikov commented Apr 19, 2015

Right now we don't do count distinct in SizeSelectToCountTransformer so it seems this does not affect us anymore.

@beikov
Copy link
Member Author

beikov commented Apr 19, 2015

We currently only do count distinct in the count query of a paginated criteria builder. If the id of an entity really is an embedded id, this won't work.

@beikov
Copy link
Member Author

beikov commented Apr 19, 2015

Since this issue is not valid anymore, we close it.

@beikov beikov closed this as completed Apr 19, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant