Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » org.eclipse.persistence.exceptions.ValidationException(Map for which the key and value are both entities)
org.eclipse.persistence.exceptions.ValidationException [message #546819] Wed, 14 July 2010 10:29 Go to next message
Guy is currently offline Guy
Messages: 3
Registered: June 2010
Junior Member
I have a 'CountryPrice' entity containing a Map for which the key and value are both entities:

@OneToMany(cascade = ALL, orphanRemoval = true)
@JoinTable(
name = "countryprice_price",
joinColumns = @JoinColumn(name = "countryprice_id", referencedColumnName = "id"),
inverseJoinColumns = @JoinColumn(name = "price_id", referencedColumnName = "id"))
@MapKeyJoinColumn(name = "country_id", referencedColumnName = "id")
public Map<Country, Price> getPrices() {
return prices;
}

The CountryPrice entities have been created and persisted in DB some time ago and normally do not change any more.
From time to time I get the validation exception below after updating other entities that reference this one. Clearing the cache seems to solve the problem for a while.

When debugging my application I found out that during the merge after the commit in the UnitOfWorkImpl class in the method

public Object getOriginalVersionOfObject(Object workingClone)

there is a key but the original object is null. As a consequence a new uninitialized Country object is put in the cache and causes the exception below for subsequent transactions. Unfortunately my knowledge about the eclipselink internals is very limited.
So any idea why the original object is null? Is there anything I can do to avoid this?

javax.persistence.RollbackException: Exception [EclipseLink-7197] (Eclipse Persistence Services - 2.0.1.v20100213-r6600): org.eclipse.persistence.exceptions.ValidationException
Exception Description: Null primary key encountered in unit of work clone [AbstractEntity{id=0} Country@0].
at org.eclipse.persistence.internal.jpa.transaction.EntityTrans actionImpl.commitInternal(EntityTransactionImpl.java:102)
at org.eclipse.persistence.internal.jpa.transaction.EntityTrans actionImpl.commit(EntityTransactionImpl.java:63)
at com.luma.w2p.servlet.LumaW2pServlet.execDoPost(LumaW2pServle t.java:267)
at com.luma.w2p.servlet.LumaW2pServlet.doPost(LumaW2pServlet.ja va:346)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFi lter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(App licationFilterChain.java:206)
at com.luma.w2p.servlet.LumaLoggingFilter.doFilter(LumaLoggingF ilter.java:57)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFi lter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(App licationFilterChain.java:206)
at org.apache.catalina.core.ApplicationDispatcher.invoke(Applic ationDispatcher.java:630)
at org.apache.catalina.core.ApplicationDispatcher.processReques t(ApplicationDispatcher.java:436)
at org.apache.catalina.core.ApplicationDispatcher.doForward(App licationDispatcher.java:374)
at org.apache.catalina.core.ApplicationDispatcher.forward(Appli cationDispatcher.java:302)
at com.luma.w2p.servlet.LumaW2pPortalRouteFilter.doFilter(LumaW 2pPortalRouteFilter.java:73)
at org.springframework.security.web.FilterChainProxy$VirtualFil terChain.doFilter(FilterChainProxy.java:355)
at com.luma.w2p.servlet.LumaW2pPortalSecurityInterceptorFilter. doFilter(LumaW2pPortalSecurityInterceptorFilter.java:96)
at org.springframework.security.web.FilterChainProxy$VirtualFil terChain.doFilter(FilterChainProxy.java:355)
at com.luma.w2p.servlet.LumaW2pPortalSignatureAuthFilter.doFilt er(LumaW2pPortalSignatureAuthFilter.java:137)
at org.springframework.security.web.FilterChainProxy$VirtualFil terChain.doFilter(FilterChainProxy.java:355)
at org.springframework.security.web.FilterChainProxy.doFilter(F ilterChainProxy.java:149)
at org.springframework.web.filter.DelegatingFilterProxy.invokeD elegate(DelegatingFilterProxy.java:237)
at org.springframework.web.filter.DelegatingFilterProxy.doFilte r(DelegatingFilterProxy.java:167)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFi lter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(App licationFilterChain.java:206)
at com.luma.w2p.servlet.LumaLoggingFilter.doFilter(LumaLoggingF ilter.java:57)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFi lter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(App licationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(Standar dWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(Standar dContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHo stValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorRepo rtValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(Standard EngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAd apter.java:286)
at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler. java:190)
at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.ja va:283)
at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java :767)
at org.apache.jk.common.ChannelSocket.processConnection(Channel Socket.java:697)
at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(Ch annelSocket.java:889)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.ru n(ThreadPool.java:690)
at java.lang.Thread.run(Thread.java:619)
Caused by: Exception [EclipseLink-7197] (Eclipse Persistence Services - 2.0.1.v20100213-r6600): org.eclipse.persistence.exceptions.ValidationException
Exception Description: Null primary key encountered in unit of work clone [AbstractEntity{id=0} Country@0].
at org.eclipse.persistence.exceptions.ValidationException.nullP rimaryKeyInUnitOfWorkClone(ValidationException.java:1403)
at org.eclipse.persistence.descriptors.changetracking.DeferredC hangeDetectionPolicy.calculateChanges(DeferredChangeDetectio nPolicy.java:106)
at org.eclipse.persistence.descriptors.changetracking.DeferredC hangeDetectionPolicy.calculateChangesForExistingObject(Defer redChangeDetectionPolicy.java:54)
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.cal culateChanges(UnitOfWorkImpl.java:624)
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.com mitToDatabaseWithChangeSet(UnitOfWorkImpl.java:1493)
at org.eclipse.persistence.internal.sessions.RepeatableWriteUni tOfWork.commitRootUnitOfWork(RepeatableWriteUnitOfWork.java: 200)
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.com mitAndResume(UnitOfWorkImpl.java:1129)
at org.eclipse.persistence.internal.jpa.transaction.EntityTrans actionImpl.commitInternal(EntityTransactionImpl.java:84)
... 41 more
Re: org.eclipse.persistence.exceptions.ValidationException [message #547148 is a reply to message #546819] Thu, 15 July 2010 17:05 Go to previous message
James Sutherland is currently offline James Sutherland
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

What are you doing to get the error, include the code.

So, if you access the Country from the cache after the commit, is its id null?

How have you mapped the id for Country?

Try the latest 2.1 release to see if the issue has been fixed.

From the stack I noticed you don't seem to be using weaving, try using static or dynamic weaving.


James : Wiki : Book : Blog : Twitter
Previous Topic:Object hierarchy create not persisting due to null parent key
Next Topic:Building object hierarchy causes synchronization
Goto Forum:
  


Current Time: Wed Sep 17 05:43:28 GMT 2014

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

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