Closed BartVansegbroeck closed 2 years ago
Yes, indeed, this is a false positive.
Anyway, the usage of LIMIT is strange as there cannot be more than one result. Ideally, Spring would have not used LIMIT and just throw an exception when there are multiple results being returned by the SQL query.
In the meanwhile, you can use an EventFilter
for this type of event so that it does not bother you until I find a good way to fix it.
The solution will scan the query AST and figure out whether the filtering is done by the entity id or natural id.
Fixed.
Method in our JPA repository
boolean existsByMerchantIdAndId(MerchantId MerchantId, CId cId)
is translated by hibernate to
Hibernate: select c0_."id" as col_0_0_ from "c_v" c0_ where c0_."merchant_id"=? and c0_."id"=? limit ?
And flagged by Hypersistence as unsorted paging event
select generatedAlias0.id from Customer as generatedAlias0 where ( generatedAlias0.merchantId=:param0 ) and ( generatedAlias0.id=:param1 )
Given that this is an exists query (hence the LIMIT 1), order is irrelevant and I would think this is a false positive.