Oliver Drotbohm (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=62861a8...
) *created* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiNmRlMzAzNmNk...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-16457?atlOrigin=eyJpIjoiNmRlMz...
) HHH-16457 (
https://hibernate.atlassian.net/browse/HHH-16457?atlOrigin=eyJpIjoiNmRlMz...
) Values returned in ValueAccess.getValues() and getValue(…) not alphabetical for Java
records (
https://hibernate.atlassian.net/browse/HHH-16457?atlOrigin=eyJpIjoiNmRlMz...
)
Issue Type: Bug Affects Versions: 6.2.0 Assignee: Unassigned Created: 11/Apr/2023 12:56 PM
Priority: Major Reporter: Oliver Drotbohm (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=62861a8...
)
The Javadoc of ValueAccess.getValues() states:
/**
* 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
*/
For a Java record declaration like this:
record MyRecord( int c, String b, LocalDate a) {}
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 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.
------------------
Steps to reproduce
------------------
$ 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)
(
https://hibernate.atlassian.net/browse/HHH-16457#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-16457#add-comment?atlOrigin=ey...
)
Get Jira notifications on your phone! Download the Jira Cloud app for Android (
https://play.google.com/store/apps/details?id=com.atlassian.android.jira....
) or iOS (
https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=Em...
) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100221- sha1:9ff53d8 )