Open mj-p opened 8 months ago
A NPE certainly is something that shouldn't happen, so yeah, there is definitely a Hibernate ORM bug lurking. Can you try with ORM 6.4.4 though?
I tested a bit more and 6.4.4 doesn't change anything.
When using one of the blaze-persistence examples with javax and version 5.6.10 the scenario actually works.
There the generated HQL has a subquery like this (SELECT COUNT(*) FROM B bs WHERE bs.a.id = a_1.id) AS PersonView_a_bsSize
instead of (SELECT Count(*) FROM a_1.bs bs) AS PersonView_a_bsSize
like with 6.4.4.
Hello, it's me again. Considering the following example, I added two new Entities named A and B where A holds a
@OneToMany
collection of Bs. Person and Cat can both hold an A.When the AView uses
@Mapping("SIZE(bs)")
and the PersonView has a@Limit
on their Kittens it produces a NPE because the "pluralAttributeMapping" for the path Person(generatedPerson_0).a(a_1).bs(bs) is nullThe produced HQL is the following:
Removing the
@Limit
results in the following HQL which works fine even though the count subquery is the same(SELECT Count(*) FROM a_1.bs bs) AS PersonView_a_bsSize,
I have zero clue yet why Hibernate likes the second one but not the first one and am wondering if this in real a Hibernate bug. Also worth noting removing the AView from either PersonView or CatView is working fine and the count part always looks like
Count(DISTINCT bs_1.id)
and only with a second AView there is a count subquery like(SELECT Count(*) FROM a_1.bs bs)
generated.Any ideas what might be going on here? Also I would have expected another join instead of a subquery, is there a reason for a subquery?
Version: 1.6.11 JPA-Provider: Hibernate 6.4.1