Ok, I've got an exception...
2011-03-09 22:29:17,230 [btpool0-2] DEBUG
org.springframework.orm.jpa.JpaTransactionManager - Initiating
transaction rollback after commit exception
org.springframework.orm.jpa.JpaSystemException:
org.hibernate.HibernateException: A collection with cascade="all-
delete-orphan" was no longer referenced by the owning entity instance:
com.happycoders.server.domain.Contact.phoneList; nested exception is
javax.persistence.PersistenceException:
org.hibernate.HibernateException: A collection with cascade="all-
delete-orphan" was no longer referenced by the owning entity instance:
com.happycoders.server.domain.Contact.phoneList
at
org.springframework.orm.jpa.EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(EntityManagerFactoryUtils.java:
311)
at
org.springframework.orm.jpa.DefaultJpaDialect.translateExceptionIfPossible(DefaultJpaDialect.java:
120)
at
org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:
471)
at
org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:
754)
at
org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:
723)
at
org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:
393)
at
org.springframework.transaction.aspectj.AbstractTransactionAspect.ajc
$afterReturning
$org_springframework_transaction_aspectj_AbstractTransactionAspect
$3$2a73e96c(AbstractTransactionAspect.aj:78)
at com.happycoders.server.domain.Contact_Roo_Entity.ajc$interMethod
$com_happycoders_server_domain_Contact_Roo_Entity
$com_happycoders_server_domain_Contact$persist(Contact_Roo_Entity.aj:
56)
at com.happycoders.server.domain.Contact.persist(Contact.java:1)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
com.google.gwt.requestfactory.server.ReflectiveServiceLayer.invoke(ReflectiveServiceLayer.java:
164)
at
com.google.gwt.requestfactory.server.ServiceLayerDecorator.invoke(ServiceLayerDecorator.java:
89)
at
com.google.gwt.requestfactory.server.ServiceLayerDecorator.invoke(ServiceLayerDecorator.java:
89)
at
com.google.gwt.requestfactory.server.SimpleRequestProcessor.processInvocationMessages(SimpleRequestProcessor.java:
440)
at
com.google.gwt.requestfactory.server.SimpleRequestProcessor.process(SimpleRequestProcessor.java:
218)
at
com.google.gwt.requestfactory.server.SimpleRequestProcessor.process(SimpleRequestProcessor.java:
125)
at
com.google.gwt.requestfactory.server.RequestFactoryServlet.doPost(RequestFactoryServlet.java:
118)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:
487)
at org.mortbay.jetty.servlet.ServletHandler
$CachedChain.doFilter(ServletHandler.java:1097)
at
org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:
113)
at
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:
76)
at org.mortbay.jetty.servlet.ServletHandler
$CachedChain.doFilter(ServletHandler.java:1088)
at
org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:
77)
at
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:
76)
at org.mortbay.jetty.servlet.ServletHandler
$CachedChain.doFilter(ServletHandler.java:1088)
at
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:
88)
at
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:
76)
at org.mortbay.jetty.servlet.ServletHandler
$CachedChain.doFilter(ServletHandler.java:1088)
at
org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:
360)
at
org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:
216)
at
org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:
181)
at
org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:
729)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:
405)
at
org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:
152)
at
org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:
49)
at
org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:
152)
at org.mortbay.jetty.Server.handle(Server.java:324)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:
505)
at org.mortbay.jetty.HttpConnection
$RequestHandler.content(HttpConnection.java:843)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:647)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
at
org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:
395)
at org.mortbay.thread.QueuedThreadPool
$PoolThread.run(QueuedThreadPool.java:488)
It looks like somewhere a new list of Phones created instead of
updating an existend one... probably by Editor framework... It cause
an original collection to be dereferenced what cause an exception.
Does anybody know a workaround?
Thx!
On Mar 9, 10:14 pm, Juan Pablo Gardella <[email protected]>
wrote:
> orphanRemoval is an entirely ORM-specific thing. It marks "child" entity to
> be removed when it's no longer referenced from the "parent" entity, e.g.
> when you remove the child entity from the corresponding collection of the
> parent entity.
> Perhaps don't remove because you have a reference in Contact to the phone
> that you want remove. Try do a Test.
>
> Juan
>
> 2011/3/9 Vasily <[email protected]>
>
> > That's fine Juan...
>
> > Actually, I'm editing Contact with Editor framework via
> > RequestFactoryEditorDriver...
> > List of phones are edited by my custom editor on the base of
> > ListEditor:
>
> > public class PhoneEditor extends Composite implements
> > IsEditor<ListEditor<PhoneProxy, PhoneEditView>> {
>
> > ...
>
> > @Override
> > public void deleteClicked(PhoneNumEditView view) {
> > int index=listEditor.getEditors().indexOf(view);
> > if(index!=-1){
> > PhoneNumProxy proxy=listEditor.getList().get(index);
> > listEditor.getList().remove(index);
> > }
>
> > }
> > ...
> > }
>
> > When delete btn clicked, I simply remove phone item from ListEditor.
> > When 'Save' btn clicked I just simply persisting Contact, so Editor
> > framework do all it's magic by mapping UI dat to object...
>
> > Again, all things stop working when I'm adding 'orphanRemoval=true' to
> > Contact annotation... Without that, I can add, edit phones in the list
> > and it works perfectly...
>
> > On Mar 9, 7:58 pm, Juan Pablo Gardella <[email protected]>
> > wrote:
> > > Sorry my english... Where are you do the operation? Paste the code
>
> > > Juan
>
> > > 2011/3/9 Juan Pablo Gardella <[email protected]>
>
> > > > Where are you this? Post the code
>
> > > > Juan
>
> > > > 2011/3/9 Vasily <[email protected]>
>
> > > > Hi All, have simple case:
>
> > > >> @RooJavaBean
> > > >> @RooToString
> > > >> @RooEntity
> > > >> public class Contact {
>
> > > >> @OneToMany(cascade=CascadeType.ALL, fetch = FetchType.EAGER,
> > > >> mappedBy="contact", orphanRemoval=true)
> > > >> private List<Phone> phoneList = new ArrayList<Phone>();
> > > >> }
>
> > > >> @RooJavaBean
> > > >> @RooToString
> > > >> @RooEntity
> > > >> public class Phone{
> > > >> private String phone;
>
> > > >> @ManyToOne(optional = false)
> > > >> private Contact contact;
> > > >> }
>
> > > >> I want to remove Phone items from DB table as soon as I'm removing
> > > >> them from Contact.phoneList so I found I can use 'orphanRemoval=true'.
>
> > > >> All works fine, until I'm adding 'orphanRemoval=true' to
> > > >> annotations... After that, I have no errors, but any changes to
> > > >> entities not persisting at all... :/
>
> > > >> MySql 5.5.8
> > > >> Hibernate 3.6.1 (3.6.0 also tested with same results)
>
> > > >> Ideas? Thx!
>
> > > >> --
> > > >> You received this message because you are subscribed to the Google
> > Groups
> > > >> "Google Web Toolkit" group.
> > > >> To post to this group, send email to
> > [email protected].
> > > >> To unsubscribe from this group, send email to
> > > >> [email protected].
> > > >> For more options, visit this group at
> > > >>http://groups.google.com/group/google-web-toolkit?hl=en.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Google Web Toolkit" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to
> > [email protected].
> > For more options, visit this group at
> >http://groups.google.com/group/google-web-toolkit?hl=en.
>
>
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en.