The Javadoc of {{ValueAccess.getValues()}} states:
{code:java}/** * Access to an individual value. * * @apiNote It is important to remember that attributes are * sorted alphabetically. So the values here will be in alphabetically * order according to the names of the corresponding attribute */{code}
For a Java record declaration like this:
{code:java}record MyRecord(int c, String b, LocalDate a) {}{code}
on Hibernate 6.1.7, {{ValueAccess.getValues()}} returns the {{LocalDate}} first, the {{String}} second, the integer last, i.e. alphabetically as defined in the Javadoc. On Hibernate 6.2, the same method invocation returns the integer first, the {{String}} second and the {{LocalDate}} last, i.e. as declared in the constructor but _not_ as specified in the Javadoc. This change of behavior is also evident when trying to access values by index , i . e. {{ValueAccess.getValue(…)}}.
h2. Steps to reproduce
{noformat}$ git clone https://github.com/odrotbohm/hibernate-bugs $ cd hibernate-bugs/embeddable-instantiator $ mvn clean test // Success - Hibernate 6.1.7 // Change hibernate.version property in pom.xml to 6.2.0.Final $ mvn clean test // See test fail with java.lang.ClassCastException: Cannot cast java.time.LocalDate to java.lang.Integer at java.base/java.lang.Class.cast(Class.java:3889) at org.hibernate.metamodel.spi.ValueAccess.getValue(ValueAccess.java:33) at example.MyRecord$MyRecordInstantiator.instantiate(MyRecord.java:56){noformat} |
|