Hello,
i have an entity with a composite primary key like this:
@IdClass(MyEntityKey.class)
public class MyEntity {
@Id
private Long id;
@Id
private OffsetDateTime bookDate;
private String data;
}
and the ID-Class
public class MyEntityKey implements Serializable {
private Long id;
private OffsetDateTime bookDate;
}
After upgrading from hibernate-core from 6.2.1 to 6.2.4 (actually upgrade from Quarkus 3.0.3 to 3.1.1) the em.find()
no longer works, but returns `null:
em.find(MyEntity.class, new MyEntityKey(ID, BOOK_DATE)); //returns null
but the same as a query works:
em
.createQuery("SELECT x FROM MyEntity x WHERE x.id = :id AND x.bookDate = :bookDate", MyEntity.class)
.setParameter("id", ID)
.setParameter("bookDate", BOOK_DATE)
.getResultList();
//returns the value
Any hints? Is this a known bug or should i create a ticket?
p.s. i found that the em.find()
create SQL like this:
Hibernate:
select
m1_0.bookDate,
m1_0.id,
m1_0.data
from
MyEntity m1_0
where
(
m1_0.bookDate,m1_0.id
) in ((?,?),(?,?),(?,?),(?,?),(?,?),(?,?),(?,?),(?,?),(?,?),(?,?),(?,?),(?,?),(?,?),(?,?),(?,?),(?,?))
This is not what I expected…a IN-query for a find?!