-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 
Author Message
 Post subject: EM3.2CR2: merge fails with detached obj in 1:1 relationship
PostPosted: Mon Sep 25, 2006 11:24 pm 
Regular
Regular

Joined: Tue May 24, 2005 9:06 am
Posts: 64
I'm using Hibernate EntityManager 3.2CR2 inside JBoss EJB3 CR9.

I'm invoking em.merge() with a detached object. The detached object has a 1:1 relationship with another detached object. The fetch strategy is the default strategy for 1:1 relationships. However, merge() fails and yields the appended stack trace.

When I enforce loading the referenced (and also detached) object, e.g. by em.find(), then there is no problem in invoking merge() afterwards. Any hint is appreciated.

Code:
javax.ejb.EJBException: java.lang.ClassCastException: de.hska.kundenverwaltung.db.Firmenkunde
at org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:69)
at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:83)
at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:197)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.aspects.security.RoleBasedAuthorizationInterceptor.invoke(RoleBasedAuthorizationInterceptor.java:167)
at org.jboss.ejb3.security.RoleBasedAuthorizationInterceptor.invoke(RoleBasedAuthorizationInterceptor.java:108)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:78)
at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:131)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:47)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:263)
at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:106)
at org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:82)
at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:828)
at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:681)
at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:358)
at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:412)
at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:239)
Caused by: java.lang.ClassCastException: de.hska.kundenverwaltung.db.Firmenkunde
at org.hibernate.type.LongType.set(LongType.java:42)
at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:83)
at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:65)
at org.hibernate.loader.Loader.bindPositionalParameters(Loader.java:1513)
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1575)
at org.hibernate.loader.Loader.doQuery(Loader.java:661)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.loadEntity(Loader.java:1784)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:48)
at org.hibernate.loader.entity.EntityLoader.loadByUniqueKey(EntityLoader.java:85)
at org.hibernate.persister.entity.AbstractEntityPersister.loadByUniqueKey(AbstractEntityPersister.java:1581)
at org.hibernate.type.EntityType.loadByUniqueKey(EntityType.java:365)
at org.hibernate.type.EntityType.resolve(EntityType.java:306)
at org.hibernate.type.EntityType.replace(EntityType.java:207)
at org.hibernate.type.TypeFactory.replace(TypeFactory.java:437)
at org.hibernate.event.def.DefaultMergeEventListener.copyValues(DefaultMergeEventListener.java:340)
at org.hibernate.event.def.DefaultMergeEventListener.entityIsDetached(DefaultMergeEventListener.java:267)
at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:120)
at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:53)
at org.hibernate.impl.SessionImpl.fireMerge(SessionImpl.java:677)
at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:661)
at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:665)
at org.hibernate.ejb.AbstractEntityManagerImpl.merge(AbstractEntityManagerImpl.java:227)
at org.jboss.ejb3.entity.TransactionScopedEntityManager.merge(TransactionScopedEntityManager.java:181)   


Top
 Profile  
 
 Post subject: Re: EM3.2CR2: merge fails with detached obj in 1:1 relations
PostPosted: Thu Sep 28, 2006 10:23 am 
Beginner
Beginner

Joined: Thu Sep 21, 2006 2:49 am
Posts: 24
I got a similar problem with the same configuration:
Code:
16:18:31,619 ERROR [STDERR] java.lang.ClassCastException: org.jboss.ejb3.entity.TransactionScopedEntityManager
16:18:31,629 ERROR [STDERR]    at $Proxy86.getEntityManager(Unknown Source)
16:18:31,629 ERROR [STDERR]    at com.dooris.util.struts.DoorISActionServlet.init(DoorISActionServlet.java:125)
16:18:31,629 ERROR [STDERR]    at javax.servlet.GenericServlet.init(GenericServlet.java:211)
16:18:31,629 ERROR [STDERR]    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1105)
16:18:31,629 ERROR [STDERR]    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:932)
16:18:31,629 ERROR [STDERR]    at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3917)
16:18:31,629 ERROR [STDERR]    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4201)

_________________
http://www.dooris.de


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 28, 2006 11:11 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
was it working with the previous version?
A simple runnable tets case will be needed then

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 28, 2006 3:13 pm 
Regular
Regular

Joined: Tue May 24, 2005 9:06 am
Posts: 64
It doesn't work with JBoss 4.0.4, too.

Testcase is provided at http://opensource.atlassian.com/project ... se/EJB-229


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 29, 2006 3:22 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
I started to look at it, but your attached project is too hairy. I've tryied to reproduce with a some simple example, no luck so far.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 30, 2006 12:28 am 
Regular
Regular

Joined: Tue May 24, 2005 9:06 am
Posts: 64
I'm out of office until Wednesday. Then I'll stepwise reduce it.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 05, 2006 10:27 am 
Regular
Regular

Joined: Tue May 24, 2005 9:06 am
Posts: 64
I simplified the testcase. Just the 2 uploaded entity files Kunde.java and Betreuer.java are sufficient [together with the attached session bean file KundenverwaltungBean.java]

http://opensource.atlassian.com/project ... se/EJB-229

1) If I invoke merge() for a modified Kunde object, then it CRASHES.
2) If I invoke merge() for a modified Betreuer object, then EVERYTHING WORKS FINE.

The difference is
1) In Kunde.java [the crashing entity]
@OneToOne(mappedBy="kunde")
private Betreuer betreuer = null;
2) Betreuer.java
@OneToOne
@JoinColumn(name="kunde_fk")
private Kunde kunde = null;

Is there a problem due to the absence of @JoinColumn?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.