Hi,
In a RESOURCE_LOCAL environment we get the following exception when we
stress test the system using 20 concurrent users. The test scenario is
quite
simple: Open new form for entity E1, fill the form, and press Save button.
Our JPA code is like this:
EntityTransaction tx = em.getTransaction()
try {
tx.begin();
em.persist(obj);
em.flush();
tx.commit();
} catch (Exception ex) {
if (tx.isActive()) tx.rollback();
ex.printStackTrace();
}
The error is as follows:
[ITO] INFO (EmaSessionListener.java:17) Initializing user configurations.
[EL Warning]: 2008.10.19
13:00:54.668--UnitOfWork(5099540)--Thread(Thread[http-8080-Processor24,5,main])--Exception
[EclipseLink-4002] (Eclipse Persistence Services - 1.0.1 (Build
20080905)):
org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: ORA-00001: unique constraint
(EMA1.SYS_C005509) violated
Error Code: 1
Call: INSERT INTO TB_EXPERTIZE (XPT_ID, XPT_CODE, XPT_WAGE,
XPT_PROFICIENCY,
XPT_LAST_UPDATE, XPT_MISSION_WAGE) VALUES (?, ?, ?, ?, ?, ?)
bind => [48054, null, 1212, poi, 2008-11-08, 1212]
Query: InsertObjectQuery(Expertize (48054))
[ITO] ERROR (BaseSession.java:205) Save object Expertize (48054) failed
for
class: Expertize
javax.persistence.PersistenceException: Exception [EclipseLink-4002]
(Eclipse Persistence Services - 1.0.1 (Build 20080905)):
org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: ORA-00001: unique constraint
(EMA1.SYS_C005509) violated
Error Code: 1
Call: INSERT INTO TB_EXPERTIZE (XPT_ID, XPT_CODE, XPT_WAGE,
XPT_PROFICIENCY,
XPT_LAST_UPDATE, XPT_MISSION_WAGE) VALUES (?, ?, ?, ?, ?, ?)
bind => [48054, null, 1212, poi, 2008-11-08, 1212]
Query: InsertObjectQuery(Expertize (48054))
at
org.eclipse.persistence.internal.jpa.EntityManagerImpl.flush(EntityManagerImpl.java:387)
at net.itorbit.ema.biz.BaseSession.save(BaseSession.java:203)
at net.itorbit.ema.biz.BaseInfoSession.save(BaseInfoSession.java:32)
at
net.itorbit.ema.action.ExpertizeAction.executeSave(ExpertizeAction.java:39)
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:585)
at
org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58)
at
org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67)
at
org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)
at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
at
org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:304)
at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
at
org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at net.itorbit.ema.helper.LocaleFilter.doFilter(LocaleFilter.java:20)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)
Caused by: Exception [EclipseLink-4002] (Eclipse Persistence Services -
1.0.1 (Build 20080905)):
org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: ORA-00001: unique constraint
(EMA1.SYS_C005509) viola
The ID annotation code in the entity is like this:
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator =
"ema_id_sq")
public Long getId() {
return id;
}
Where ema_id_sq is:
@SequenceGenerator(name = "ema_id_sq")
Thanks,
Mohsen.
--
View this message in context:
http://www.nabble.com/Non-transactional-sequenced-ID-generation-causes-unique-constraint-violation-tp20054596p20054596.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users