org.springframework.orm.jpa.JpaSystemException: Error accessing field [public java.lang.String com.casa.fabbookingbase.entity.AbstractBookingEntity.roomNightBookingId] by reflection for persistent property [com.casa.fabbookingbase.entity.RoomNightEntity#roomNightBookingId] : 2; nested exception is org.hibernate.property.access.spi.PropertyAccessException: Error accessing field [public java.lang.String com.casa.fabbookingbase.entity.AbstractBookingEntity.roomNightBookingId] by reflection for persistent property [com.casa.fabbookingbase.entity.RoomNightEntity#roomNightBookingId] : 2


Solutions on the web74

Solution icon of stackoverflow
Error accessing field [public java.lang.String com.casa.fabbookingbase.entity.AbstractBookingEntity.roomNightBookingId] by reflection for persistent property [com.casa.fabbookingbase.entity.RoomNightEntity#roomNightBookingId] : 2; nested exception

Solution icon of hibernate
via Hibernate JIRA by K, 7 months ago
Error accessing field [private java.lang.String com.example.domain.Entity.myString] by reflection for persistent property [com.example.domain.Entity#myString] : MYTEST; nested exception is org.hibernate.property.access.spi.PropertyAccessException

Solution icon of stackoverflow
Error accessing field [private java.lang.Integer com.etisoftware.workorderprinting.beans.cborg.WorkOrderOwner.number] by reflection for persistent property [com.etisoftware.workorderprinting.beans.cborg.WorkOrderOwner#number] : 1; nested exception

Solution icon of stackoverflow
Could not set field value [2] value by reflection : [class com.dto.Product.productId] setter of com.dto.Product.productId; nested exception is org.hibernate.PropertyAccessException: Could not set field value [2] value by reflection : [class com.dto.Product.productId] setter of com.dto.Product.productId

Solution icon of stackoverflow
could not get a field value by reflection getter of com.tracebucket.partner.domain.PartnerRole.id; nested exception is org.hibernate.PropertyAccessException: could not get a field value by reflection getter of com.tracebucket.partner.domain.PartnerRole.id

Solution icon of stackoverflow
could not set a field value by reflection setter of com.lotjm.domain.Memberships$MembershipsPK.user; nested exception is org.hibernate.PropertyAccessException: could not set a field value by reflection setter of com.lotjm.domain.Memberships$MembershipsPK.user

Solution icon of web
could not get a field value by reflection getter of com.tracebucket.partner.domain.PartnerRole.id; nested exception is org.hibernate.PropertyAccessException: could not get a field value by reflection getter of com.tracebucket.partner.domain.PartnerRole.id

Solution icon of hibernate
via Hibernate JIRA by Oliver Gierke, 1 year ago
Error preparing CallableStatement; nested exception is org.hibernate.exception.GenericJDBCException: Error preparing CallableStatement

Solution icon of web
Error preparing CallableStatement; nested exception is org.hibernate.exception.GenericJDBCException: Error preparing CallableStatement

Solution icon of hibernate
via Hibernate JIRA by Oliver Gierke, 1 year ago
Error preparing CallableStatement; nested exception is org.hibernate.exception.GenericJDBCException: Error preparing CallableStatement

Stack trace

org.springframework.orm.jpa.JpaSystemException: Error accessing field [public java.lang.String com.casa.fabbookingbase.entity.AbstractBookingEntity.roomNightBookingId] by reflection for persistent property [com.casa.fabbookingbase.entity.RoomNightEntity#roomNightBookingId] : 2; nested exception is org.hibernate.property.access.spi.PropertyAccessException: Error accessing field [public java.lang.String com.casa.fabbookingbase.entity.AbstractBookingEntity.roomNightBookingId] by reflection for persistent property [com.casa.fabbookingbase.entity.RoomNightEntity#roomNightBookingId] : 2
	at org.springframework.orm.jpa.vendor.HibernateJpaDialect.convertHibernateAccessException(HibernateJpaDialect.java:314)
	at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:225)
	at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.translateExceptionIfPossible(AbstractEntityManagerFactoryBean.java:436)
	at org.springframework.dao.support.ChainedPersistenceExceptionTranslator.translateExceptionIfPossible(ChainedPersistenceExceptionTranslator.java:59)
	at org.springframework.dao.support.DataAccessUtils.translateIfNecessary(DataAccessUtils.java:213)
	at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:147)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
	at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:133)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
	at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)
	at com.sun.proxy.$Proxy65.deleteByBookingId(Unknown Source)
	at com.casa.fabbooking.service.BookingServiceTest.testDeleteBooking(BookingServiceTest.java:179)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:497)
	at org.springframework.test.context.junit4.SpringTestMethod.invoke(SpringTestMethod.java:160)
	at org.springframework.test.context.junit4.SpringMethodRoadie.runTestMethod(SpringMethodRoadie.java:233)
	at org.springframework.test.context.junit4.SpringMethodRoadie$RunBeforesThenTestThenAfters.run(SpringMethodRoadie.java:333)
	at org.springframework.test.context.junit4.SpringMethodRoadie.runWithRepetitions(SpringMethodRoadie.java:217)
	at org.springframework.test.context.junit4.SpringMethodRoadie.runTest(SpringMethodRoadie.java:197)
	at org.springframework.test.context.junit4.SpringMethodRoadie.run(SpringMethodRoadie.java:143)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.invokeTestMethod(SpringJUnit4ClassRunner.java:160)
	at org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51)
	at org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44)
	at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)
	at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
	at org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:97)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: org.hibernate.property.access.spi.PropertyAccessException: Error accessing field [public java.lang.String com.casa.fabbookingbase.entity.AbstractBookingEntity.roomNightBookingId] by reflection for persistent property [com.casa.fabbookingbase.entity.RoomNightEntity#roomNightBookingId] : 2
	at org.hibernate.property.access.spi.GetterFieldImpl.get(GetterFieldImpl.java:43)
	at org.hibernate.tuple.component.AbstractComponentTuplizer.getPropertyValue(AbstractComponentTuplizer.java:58)
	at org.hibernate.type.ComponentType.getPropertyValue(ComponentType.java:414)
	at org.hibernate.type.ComponentType.getHashCode(ComponentType.java:238)
	at org.hibernate.engine.spi.EntityUniqueKey.generateHashCode(EntityUniqueKey.java:67)
	at org.hibernate.engine.spi.EntityUniqueKey.<init>(EntityUniqueKey.java:48)
	at org.hibernate.type.EntityType.loadByUniqueKey(EntityType.java:679)
	at org.hibernate.type.EntityType.resolve(EntityType.java:427)
	at org.hibernate.engine.internal.TwoPhaseLoad.doInitializeEntity(TwoPhaseLoad.java:151)
	at org.hibernate.engine.internal.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:125)
	at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:1132)
	at org.hibernate.loader.Loader.processResultSet(Loader.java:992)
	at org.hibernate.loader.Loader.doQuery(Loader.java:930)
	at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:336)
	at org.hibernate.loader.Loader.doList(Loader.java:2610)
	at org.hibernate.loader.Loader.doList(Loader.java:2593)
	at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2422)
	at org.hibernate.loader.Loader.list(Loader.java:2417)
	at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:501)
	at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:371)
	at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:216)
	at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1339)
	at org.hibernate.internal.QueryImpl.list(QueryImpl.java:87)
	at org.hibernate.jpa.internal.QueryImpl.list(QueryImpl.java:606)
	at org.hibernate.jpa.internal.QueryImpl.getResultList(QueryImpl.java:483)
	at org.hibernate.jpa.criteria.compile.CriteriaQueryTypeQueryAdapter.getResultList(CriteriaQueryTypeQueryAdapter.java:50)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:497)
	at org.springframework.orm.jpa.SharedEntityManagerCreator$DeferredQueryInvocationHandler.invoke(SharedEntityManagerCreator.java:368)
	at com.sun.proxy.$Proxy90.getResultList(Unknown Source)
	at org.springframework.data.jpa.repository.query.JpaQueryExecution$DeleteExecution.doExecute(JpaQueryExecution.java:275)
	at org.springframework.data.jpa.repository.query.JpaQueryExecution.execute(JpaQueryExecution.java:82)
	at org.springframework.data.jpa.repository.query.AbstractJpaQuery.doExecute(AbstractJpaQuery.java:116)
	at org.springframework.data.jpa.repository.query.AbstractJpaQuery.execute(AbstractJpaQuery.java:106)
	at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:482)
	at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:460)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
	at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:61)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
	at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
	at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281)
	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
	at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136)
	... 31 more
Caused by: java.lang.IllegalArgumentException: Can not set java.lang.String field com.casa.fabbookingbase.entity.AbstractBookingEntity.roomNightBookingId to java.lang.Long
	at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:167)
	at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:171)
	at sun.reflect.UnsafeFieldAccessorImpl.ensureObj(UnsafeFieldAccessorImpl.java:58)
	at sun.reflect.UnsafeObjectFieldAccessorImpl.get(UnsafeObjectFieldAccessorImpl.java:36)
	at java.lang.reflect.Field.get(Field.java:393)
	at org.hibernate.property.access.spi.GetterFieldImpl.get(GetterFieldImpl.java:39)
	... 76 more

Write tip

You have a different solution? A short tip here would help you and many other users who saw this issue last week.

Users with the same issue

20 times, 7 months ago
Samebug visitor profile picture
Unknown user
Once, 1 year ago
Samebug visitor profile picture
Unknown user
Once, 1 year ago
Samebug visitor profile picture
Unknown user
Once, 1 year ago
Samebug visitor profile picture
Unknown user
Once, 1 year ago
61 more bugmates