Closed jwgmeligmeyling closed 6 years ago
I'm wondering though how this could easily be changed. While uniqueness is preserved using the MIN
, MAX
and SUM
functions, it wouldn't work for COUNT
and potentially others.
I think it also fails for compound keys. Paginating on orderByAsc("entity.compoundKeyA").orderByAsc("entity.compoundKeyB")
, which is actually unique when used together, but given the current implementation I think it "works" because it assumes entity.compoundKeyB
is unique, which it is not. But this may just be related to the lacking support for @IdClass
in general, I haven't tried it with EmbeddedIds
.
Not sure about @IdClass
support, but at least embedded ids work. We have quite a few models with embedded ids and they work all fine. Note that keyset-pagination with compound keys is currently broken, maybe you are hitting a problem there?
Anyway, the uniqueness analysis is more or less broken and currently only catches the most obvious usage errors. You got to be careful for now with @IdClass
uses
Didn't run into it yet, just scribbled down that, while fixing this, we should address:
isUnique
seems to return true for parts of compound keys, if this is so, this needs addressing (unfortunately this will break valid paginations that now work, so ideally this is fixed in conjunction with the following)
ExpressionUtils.isUnique(..., PathExpression) always returns false. This isn't always correct. For example:
MIN(id)
,MAX(id)
,SUM(id)
are still guaranteed to be unique, ifid
is unique. Related to #568 as this could have been an easy work around.Description
Expected behavior
Actual behavior
Steps to reproduce
Environment
Version:
JPA-Provider:
DBMS:
Application Server: