Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [Texo] Persist already deleted objects
[Texo] Persist already deleted objects [message #1033367] Thu, 04 April 2013 06:59 Go to next message
Bastian Wagenfeld is currently offline Bastian WagenfeldFriend
Messages: 183
Registered: January 2013
Senior Member
Hi Martin,

I ran into another problem, which I could bypass. But I thought this could be interesting for you, or you could tell me how to deal with it in another way.

A user has an option to delete an object. After that, these changes will be committed to the database immediately. Now, he can undo these deletion. So the object (and its ID) will be restored and committed immediately, also. That leads to an exception, because this object cannot be merged:
[EL Warning]: 2013-04-04 08:40:50.332--UnitOfWork(20501487)--javax.persistence.OptimisticLockException: Exception [EclipseLink-5006] (Eclipse Persistence Services - 2.4.1.v20121003-ad44345): org.eclipse.persistence.exceptions.OptimisticLockException
Exception Description: The object [Customer  [name: Customer] [description: Description for Customer]] cannot be updated because it has changed or been deleted since it was last read. 
Class> de.test.test.texo.model.Customer Primary Key> 1.722
	at org.eclipse.persistence.internal.sessions.RepeatableWriteUnitOfWork.commitToDatabase(RepeatableWriteUnitOfWork.java:636)
	at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.commitToDatabaseWithPreBuiltChangeSet(UnitOfWorkImpl.java:1565)
	at org.eclipse.persistence.internal.sessions.RepeatableWriteUnitOfWork.writeChanges(RepeatableWriteUnitOfWork.java:445)
	at org.eclipse.persistence.internal.jpa.EntityManagerImpl.flush(EntityManagerImpl.java:798)
	at org.eclipse.emf.texo.server.store.EntityManagerObjectStore.flush(EntityManagerObjectStore.java:267)
	at org.eclipse.emf.texo.server.service.UpdateInsertModelOperation.internalExecute(UpdateInsertModelOperation.java:109)
	at org.eclipse.emf.texo.server.service.ModelOperation.execute(ModelOperation.java:59)
	at org.eclipse.emf.texo.server.web.WebServiceHandler.doPost(WebServiceHandler.java:111)
	at org.eclipse.emf.texo.server.web.WebServiceServlet.doPost(WebServiceServlet.java:65)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
	at de.test.test.filter.DatabaseSwitchFilter.doFilter(DatabaseSwitchFilter.java:38)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
	at java.lang.Thread.run(Thread.java:722)


To avoid this I manually remove all IDs, which seems to work.

Best regards
Bastian
Re: [Texo] Persist already deleted objects [message #1033395 is a reply to message #1033367] Thu, 04 April 2013 07:36 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Bastian,
Yes this is expected behavior from the persistence layer and your solution is fine also. You can also try by setting the
db version (if you have that property) to null (instead of the id). That could be enough to.

gr. Martin

On 04/04/2013 08:59 AM, Bastian Wagenfeld wrote:
> Hi Martin,
>
> I ran into another problem, which I could bypass. But I thought this could be interesting for you, or you could tell me
> how to deal with it in another way.
>
> A user has an option to delete an object. After that, these changes will be committed to the database immediately. Now,
> he can undo these deletion. So the object (and its ID) will be restored and committed immediately, also. That leads to
> an exception, because this object cannot be merged:
> [EL Warning]: 2013-04-04 08:40:50.332--UnitOfWork(20501487)--javax.persistence.OptimisticLockException: Exception
> [EclipseLink-5006] (Eclipse Persistence Services - 2.4.1.v20121003-ad44345):
> org.eclipse.persistence.exceptions.OptimisticLockException
> Exception Description: The object [Customer [name: Customer] [description: Description for Customer]] cannot be updated
> because it has changed or been deleted since it was last read. Class> de.test.test.texo.model.Customer Primary Key> 1.722
> at
> org.eclipse.persistence.internal.sessions.RepeatableWriteUnitOfWork.commitToDatabase(RepeatableWriteUnitOfWork.java:636)
> at
> org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.commitToDatabaseWithPreBuiltChangeSet(UnitOfWorkImpl.java:1565)
> at
> org.eclipse.persistence.internal.sessions.RepeatableWriteUnitOfWork.writeChanges(RepeatableWriteUnitOfWork.java:445)
> at org.eclipse.persistence.internal.jpa.EntityManagerImpl.flush(EntityManagerImpl.java:798)
> at org.eclipse.emf.texo.server.store.EntityManagerObjectStore.flush(EntityManagerObjectStore.java:267)
> at org.eclipse.emf.texo.server.service.UpdateInsertModelOperation.internalExecute(UpdateInsertModelOperation.java:109)
> at org.eclipse.emf.texo.server.service.ModelOperation.execute(ModelOperation.java:59)
> at org.eclipse.emf.texo.server.web.WebServiceHandler.doPost(WebServiceHandler.java:111)
> at org.eclipse.emf.texo.server.web.WebServiceServlet.doPost(WebServiceServlet.java:65)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
> at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
> at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
> at de.test.test.filter.DatabaseSwitchFilter.doFilter(DatabaseSwitchFilter.java:38)
> at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
> at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
> at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
> at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
> at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
> at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
> at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
> at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
> at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
> at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
> at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
> at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
> at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
> at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
> at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
> at java.lang.Thread.run(Thread.java:722)
> To avoid this I manually remove all IDs, which seems to work.
>
> Best regards
> Bastian


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Re: [Texo] Persist already deleted objects [message #1033402 is a reply to message #1033395] Thu, 04 April 2013 07:46 Go to previous message
Bastian Wagenfeld is currently offline Bastian WagenfeldFriend
Messages: 183
Registered: January 2013
Senior Member
Hi Martin,

thanks, good to know Smile
Removing the version works, too. Also it seems to be the better approach. Thank you!

Bastian
Previous Topic:[Texo] Questions regarding the generated Testdata and other stuff
Next Topic:EPackageImpl.ePackageExtendedMetaData.nameToClassifierMap not updated when classifier removed
Goto Forum:
  


Current Time: Tue Mar 19 08:57:43 GMT 2024

Powered by FUDForum. Page generated in 0.02793 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top