Hello
I have a ManyToMany relationship between two entities in my database. First i tried the Eager approach and everything was working fine. Then i tried to shift from Eager to the lazy loading approach and i am facing problems since then.
I found a tutorial at
http://anonhibernate.labs.jboss.com/tags/annotations_v30beta1/HibernateExt/metadata/test/org/hibernate/test/annotations/manytomany/ManyToManyTest.java.
My scenario is similar to the Employer & Employee example given here and did exactly what was mentioned there. But now i am getting the following exception:
Code:
2007-04-17 11:46:13,104 ERROR [STDERR] javax.persistence.PersistenceException: org.hibernate.PropertyAccessException: could not get a field value by reflection getter of temps.Userprofile.id
2007-04-17 11:46:13,104 ERROR [STDERR] at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:567)
2007-04-17 11:46:13,104 ERROR [STDERR] at org.hibernate.ejb.AbstractEntityManagerImpl.merge(AbstractEntityManagerImpl.java:210)
2007-04-17 11:46:13,104 ERROR [STDERR] at org.jboss.ejb3.entity.TransactionScopedEntityManager.merge(TransactionScopedEntityManager.java:181)
2007-04-17 11:46:13,119 ERROR [STDERR] at sessions.FacilitywatchFacade.edit(FacilitywatchFacade.java:52)
2007-04-17 11:46:13,135 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2007-04-17 11:46:13,135 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
2007-04-17 11:46:13,135 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
2007-04-17 11:46:13,135 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:585)
2007-04-17 11:46:13,135 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
2007-04-17 11:46:13,135 ERROR [STDERR] at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
2007-04-17 11:46:13,135 ERROR [STDERR] at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
2007-04-17 11:46:13,135 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
2007-04-17 11:46:13,135 ERROR [STDERR] at org.jboss.ejb3.entity.ExtendedPersistenceContextPropagationInterceptor.invoke(ExtendedPersistenceContextPropagationInterceptor.java:57)
2007-04-17 11:46:13,135 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
2007-04-17 11:46:13,135 ERROR [STDERR] at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
2007-04-17 11:46:13,150 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
2007-04-17 11:46:13,150 ERROR [STDERR] at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
2007-04-17 11:46:13,150 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
2007-04-17 11:46:13,150 ERROR [STDERR] at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
2007-04-17 11:46:13,150 ERROR [STDERR] at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:197)
2007-04-17 11:46:13,150 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
2007-04-17 11:46:13,150 ERROR [STDERR] at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
2007-04-17 11:46:13,150 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
2007-04-17 11:46:13,150 ERROR [STDERR] at org.jboss.ejb3.stateful.StatefulInstanceInterceptor.invoke(StatefulInstanceInterceptor.java:81)
2007-04-17 11:46:13,150 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
2007-04-17 11:46:13,150 ERROR [STDERR] at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:78)
2007-04-17 11:46:13,150 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
2007-04-17 11:46:13,150 ERROR [STDERR] at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:47)
2007-04-17 11:46:13,150 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
2007-04-17 11:46:13,150 ERROR [STDERR] at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
2007-04-17 11:46:13,150 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
2007-04-17 11:46:13,150 ERROR [STDERR] at org.jboss.ejb3.stateful.StatefulContainer.dynamicInvoke(StatefulContainer.java:297)
2007-04-17 11:46:13,150 ERROR [STDERR] at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:106)
2007-04-17 11:46:13,150 ERROR [STDERR] at org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:82)
2007-04-17 11:46:13,150 ERROR [STDERR] at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:828)
2007-04-17 11:46:13,150 ERROR [STDERR] at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:681)
2007-04-17 11:46:13,150 ERROR [STDERR] at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:358)
2007-04-17 11:46:13,150 ERROR [STDERR] at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:412)
2007-04-17 11:46:13,150 ERROR [STDERR] at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:239)
2007-04-17 11:46:13,150 ERROR [STDERR] Caused by: org.hibernate.PropertyAccessException: could not get a field value by reflection getter of temps.Userprofile.id
2007-04-17 11:46:13,150 ERROR [STDERR] at org.hibernate.property.DirectPropertyAccessor$DirectGetter.get(DirectPropertyAccessor.java:35)
2007-04-17 11:46:13,150 ERROR [STDERR] at org.hibernate.tuple.AbstractEntityTuplizer.getIdentifier(AbstractEntityTuplizer.java:176)
2007-04-17 11:46:13,150 ERROR [STDERR] at org.hibernate.persister.entity.AbstractEntityPersister.getIdentifier(AbstractEntityPersister.java:3368)
2007-04-17 11:46:13,150 ERROR [STDERR] at org.hibernate.persister.entity.AbstractEntityPersister.isTransient(AbstractEntityPersister.java:3084)
2007-04-17 11:46:13,150 ERROR [STDERR] at org.hibernate.engine.ForeignKeys.isTransient(ForeignKeys.java:181)
2007-04-17 11:46:13,150 ERROR [STDERR] at org.hibernate.event.def.AbstractSaveEventListener.getEntityState(AbstractSaveEventListener.java:487)
2007-04-17 11:46:13,150 ERROR [STDERR] at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:90)
2007-04-17 11:46:13,150 ERROR [STDERR] at org.hibernate.impl.SessionImpl.fireMerge(SessionImpl.java:689)
2007-04-17 11:46:13,150 ERROR [STDERR] at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:671)
2007-04-17 11:46:13,150 ERROR [STDERR] at org.hibernate.engine.CascadingAction$6.cascade(CascadingAction.java:156)
2007-04-17 11:46:13,150 ERROR [STDERR] at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:213)
2007-04-17 11:46:13,150 ERROR [STDERR] at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:157)
2007-04-17 11:46:13,150 ERROR [STDERR] at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:108)
2007-04-17 11:46:13,150 ERROR [STDERR] at org.hibernate.engine.Cascade.cascadeCollectionElements(Cascade.java:290)
2007-04-17 11:46:13,150 ERROR [STDERR] at org.hibernate.engine.Cascade.cascadeCollection(Cascade.java:185)
2007-04-17 11:46:13,150 ERROR [STDERR] at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:160)
2007-04-17 11:46:13,150 ERROR [STDERR] at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:108)
2007-04-17 11:46:13,150 ERROR [STDERR] at org.hibernate.engine.Cascade.cascade(Cascade.java:248)
2007-04-17 11:46:13,150 ERROR [STDERR] at org.hibernate.event.def.DefaultMergeEventListener.cascadeOnMerge(DefaultMergeEventListener.java:332)
2007-04-17 11:46:13,150 ERROR [STDERR] at org.hibernate.event.def.DefaultMergeEventListener.entityIsDetached(DefaultMergeEventListener.java:245)
2007-04-17 11:46:13,150 ERROR [STDERR] at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:99)
2007-04-17 11:46:13,150 ERROR [STDERR] at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:51)
2007-04-17 11:46:13,150 ERROR [STDERR] at org.hibernate.impl.SessionImpl.fireMerge(SessionImpl.java:679)
2007-04-17 11:46:13,150 ERROR [STDERR] at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:663)
2007-04-17 11:46:13,150 ERROR [STDERR] at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:667)
2007-04-17 11:46:13,150 ERROR [STDERR] at org.hibernate.ejb.AbstractEntityManagerImpl.merge(AbstractEntityManagerImpl.java:201)
2007-04-17 11:46:13,150 ERROR [STDERR] ... 37 more
2007-04-17 11:46:13,150 ERROR [STDERR] Caused by: java.lang.IllegalArgumentException
2007-04-17 11:46:13,150 ERROR [STDERR] at sun.reflect.UnsafeFieldAccessorImpl.ensureObj(UnsafeFieldAccessorImpl.java:37)
2007-04-17 11:46:13,150 ERROR [STDERR] at sun.reflect.UnsafeObjectFieldAccessorImpl.get(UnsafeObjectFieldAccessorImpl.java:18)
2007-04-17 11:46:13,150 ERROR [STDERR] at java.lang.reflect.Field.get(Field.java:357)
2007-04-17 11:46:13,150 ERROR [STDERR] at org.hibernate.property.DirectPropertyAccessor$DirectGetter.get(DirectPropertyAccessor.java:32)
2007-04-17 11:46:13,150 ERROR [STDERR] ... 62 more
Can anyone please help!
Thanks