Error accessing field [SOME_FIELD] by reflection for persistent property - Caused by: java.lang.IllegalArgumentException
Description
Activity
Show:
Laurent Dauvilaire June 23, 2022 at 1:54 PM
Same for me, cannot upgrade to version > 5.4.33 because of this bug ( and using java 8, using oracle partitionning with composite keys)
Fernando Tsuda May 31, 2022 at 4:56 PM
Forget to add link to another issue with the same error output: https://hibernate.atlassian.net/browse/HHH-15277
Details
Details
Assignee
Unassigned
UnassignedReporter
Fernando Tsuda
Fernando TsudaWorked in
Components
Priority
Created May 31, 2022 at 4:51 PM
Updated June 23, 2022 at 1:54 PM
After Spring Boot migration from 2.5.14 to 2.6 (or 2.7), this error started to show when i try to save some related entities to database:
javax.persistence.PersistenceException: org.hibernate.property.access.spi.PropertyAccessException: Error accessing field [protected java.lang.Long com.example.datajpaerror.entity.DocumentEntityId.personId] by reflection for persistent property [com.example.datajpaerror.entity.DocumentEntityId#personId] : 1 at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:154) Caused by: org.hibernate.property.access.spi.PropertyAccessException: Error accessing field [protected java.lang.Long com.example.datajpaerror.entity.DocumentEntityId.personId] by reflection for persistent property [com.example.datajpaerror.entity.DocumentEntityId#personId] : 1 at org.hibernate.property.access.spi.GetterFieldImpl.get(GetterFieldImpl.java:75) Caused by: java.lang.IllegalArgumentException: Can not set java.lang.Long field com.example.datajpaerror.entity.DocumentEntityId.personId to java.lang.Long at java.base/jdk.internal.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:167)
Since i'm using a quite complex Entity mapping configuration that involves inheritance and multi-column Primary Keys with EmbeddedId, i've wrote a small application in order to reproduce this error (with help of Spring Boot's Jens Schauder to convert into a pure Hibernate Application). This application can be found at https://github.com/ftsuda-senac/data-jpa-error (detailed stacktrace is on README.md)
Steps to reproduce the error:
After downloading the application mentioned above, run as mvn test
A successful test can be achieved changing the Hibernate version to 5.4.13.Final and running the same command mvn test