PropertyAccessException on persistence of a simple entity with no relations or fields other than the PK

Description

The following exception is thrown when trying to persist a new "Product" entity (see test case) by Hibernate 4.3.6.FINAL. However, it works perfectly fine if I change the maven dependency to 4.3.5.FINAL without touching any other piece of code.

A RequestScoped bean handles a commandButton on a JSF page, and uses a Stateless bean to create a new entity. If you deploy the test case and go to http://localhost:8080/example_app/faces/index.xhtml (default Glassfish port for domain1), then you'll see a blank button; clicking on it attempts to make the DB insert.

The product class is just:

Attachments

1

Activity

Show:

joyous javadev May 9, 2015 at 1:42 AM

I ran into this issue in v4.3.9.Final. Based on the marked duplicate HHH-9446, my assumption is that the issue should have been already fixed in v4.3.9.Final, I downgraded to v4.3.5.Final and my issue below was not reproducible. I am using JDK 1.8.0_40, Glassfish v4.1

*Testcase:*

Stack trace:

Caused by: javax.persistence.PersistenceException: org.hibernate.PropertyAccessException: could not get a field value by reflection getter of com.test.entity.User.id
at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1763) ~[hibernate-entitymanager-4.3.9.Final.jar:?]
at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1677) ~[hibernate-entitymanager-4.3.9.Final.jar:?]
at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1683) ~[hibernate-entitymanager-4.3.9.Final.jar:?]
at org.hibernate.jpa.spi.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:1187) ~[hibernate-entitymanager-4.3.9.Final.jar:?]
at com.sun.enterprise.container.common.impl.EntityManagerWrapper.persist(EntityManagerWrapper.java:287) ~[container-common.jar:?]
...
...

Caused by: org.hibernate.PropertyAccessException: could not get a field value by reflection getter of com.test.entity.User.id
at org.hibernate.property.DirectPropertyAccessor$DirectGetter.get(DirectPropertyAccessor.java:60) ~[hibernate-core-4.3.9.Final.jar:?]
at org.hibernate.tuple.entity.AbstractEntityTuplizer.getIdentifier(AbstractEntityTuplizer.java:346) ~[hibernate-core-4.3.9.Final.jar:?]
at org.hibernate.persister.entity.AbstractEntityPersister.getIdentifier(AbstractEntityPersister.java:4746) ~[hibernate-core-4.3.9.Final.jar:?]
at org.hibernate.persister.entity.AbstractEntityPersister.isTransient(AbstractEntityPersister.java:4465) ~[hibernate-core-4.3.9.Final.jar:?]
at org.hibernate.engine.internal.ForeignKeys.isTransient(ForeignKeys.java:243) ~[hibernate-core-4.3.9.Final.jar:?]

Brett Meyer April 22, 2015 at 9:14 PM

Closing rejected issues.

Tadas Giniotis April 11, 2015 at 3:56 PM
Edited

Had the same problem with Hibernate 4.3.8.Final. Downgrading to 4.3.5.Final helped.

Server: GlassFish Server Open Source Edition 4.1 (build 13)

Philipp Nanz October 22, 2014 at 12:59 PM

Shouldn't your getter read public int getId()

Former user October 22, 2014 at 12:53 PM

The "envers" tables have not been also created automatically by this release (Hibernate 4.3.6). 4.3.5 works fine, but I need to update to 4.3.6 for getting the new functionality regarding to entity copies.

Duplicate

Details

Assignee

Reporter

Affects versions

Priority

Created October 9, 2014 at 5:28 AM
Updated May 9, 2015 at 1:42 AM
Resolved April 11, 2015 at 8:59 PM