我需要在JPA中提交此事务。当我提交此事务时,它显示了我在使用复合主对象时的独特约束,否则ot可以正常工作
public Set<Servergroupdtl>
saveservergroupdtl(DataHolder
apidocDataHolder,EntityManager entitymanager,String serverGroupId)
{
Servergroupdtl serverGroupDtl = new Servergroupdtl();
ServergroupdtlPK serverGroupDtlPk =new ServergroupdtlPK();
Set<Servergroupdtl> servergroupdtls = new HashSet<Servergroupdtl>();
MatrixField servergroupdtlMatrixField = new MatrixField();
LinkedList<LinkedHashMap<String, Field>> matrixData=null;
try
{
Field serverGroupDtlField =
apidocDataHolder.getField
("APIDocRepository.ServerGroup.ServerGroupDetails",".");
if(serverGroupDtlField instanceof MatrixField)
{
servergroupdtlMatrixField = (MatrixField)
serverGroupDtlField;
matrixData = servergroupdtlMatrixField.getMatrixData();
}
for(LinkedHashMap<String, Field> serverGroupDtlList : matrixData)
{
serverGroupDtl.setEnable(serverGroupDtlList.get("Enable").toString());
serverGroupDtlPk.setServerGroupId(serverGroupId);
String severGroupDtlId = serverGroupDtlList.get("ServerID").toString();
serverGroupDtlPk.setServerId(serverGroupDtlList.get("ServerID").toString());
serverGroupDtl.setId(serverGroupDtlPk);
servergroupdtls.add(serverGroupDtl);
deleteserverGroupDtl(severGroupDtlId,serverGroupId,entitymanager);
presistservergroupdtl(serverGroupDtl,entitymanager);
}
}
catch(Exception e)
{
e.printStackTrace();
}
return servergroupdtls;
}
堆栈跟踪
17:30:07,798 WARN [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (default task-12) SQL Error: 1, SQLState: 23000
17:30:07,801 ERROR [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (default task-12) ORA-00001: unique constraint (OFDEVNEW.SERVERGROUPDTL_PK) violated
17:30:07,807 INFO [org.hibernate.engine.jdbc.batch.internal.AbstractBatchImpl] (default task-12) HHH000010: On release of batch it still contained JDBC statements
17:30:52,063 ERROR [stderr] (default task-12) javax.transaction.RollbackException: ARJUNA016053: Could not commit transaction.
17:30:52,085 ERROR [stderr] (default task-12) at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1212)
17:30:52,097 ERROR [stderr] (default task-12) at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.commit(BaseTransaction.java:126)
17:30:52,117 ERROR [stderr] (default task-12) at com.arjuna.ats.jbossatx.BaseTransactionManagerDelegate.commit(BaseTransactionManagerDelegate.java:89)
17:30:52,125 ERROR [stderr] (default task-12) at org.jboss.tm.usertx.client.ServerVMClientUserTransaction.commit(ServerVMClientUserTransaction.java:178)
17:30:52,141 ERROR [stderr] (default task-12) at Artifact.ServiceCalls.servicecall(ServiceCalls.java:43)
17:30:52,145 ERROR [stderr] (default task-12) at Artifact.ArtifactService.doGet(ArtifactService.java:33)
17:30:52,149 ERROR [stderr] (default task-12) at javax.servlet.http.HttpServlet.service(HttpServlet.java:687)
17:30:52,157 ERROR [stderr] (default task-12) at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
17:30:52,161 ERROR [stderr] (default task-12) at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)
17:30:52,169 ERROR [stderr] (default task-12) at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
17:30:52,173 ERROR [stderr] (default task-12) at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
17:30:52,177 ERROR [stderr] (default task-12) at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
17:30:52,185 ERROR [stderr] (default task-12) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
17:30:52,189 ERROR [stderr] (default task-12) at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)
17:30:52,193 ERROR [stderr] (default task-12) at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
17:30:52,197 ERROR [stderr] (default task-12) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
17:30:52,205 ERROR [stderr] (default task-12) at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
17:30:52,205 ERROR [stderr] (default task-12) at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
17:30:52,209 ERROR [stderr] (default task-12) at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)
17:30:52,213 ERROR [stderr] (default task-12) at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)
17:30:52,213 ERROR [stderr] (default task-12) at io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)
17:30:52,217 ERROR [stderr] (default task-12) at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
17:30:52,221 ERROR [stderr] (default task-12) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
17:30:52,221 ERROR [stderr] (default task-12) at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
17:30:52,225 ERROR [stderr] (default task-12) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
17:30:52,229 ERROR [stderr] (default task-12) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
17:30:52,229 ERROR [stderr] (default task-12) at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:285)
17:30:52,233 ERROR [stderr] (default task-12) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:264)
17:30:52,233 ERROR [stderr] (default task-12) at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)
17:30:52,237 ERROR [stderr] (default task-12) at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:175)
17:30:52,241 ERROR [stderr] (default task-12) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:202)
17:30:52,241 ERROR [stderr] (default task-12) at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:792)
17:30:52,241 ERROR [stderr] (default task-12) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
17:30:52,245 ERROR [stderr] (default task-12) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
17:30:52,245 ERROR [stderr] (default task-12) at java.lang.Thread.run(Thread.java:745)
17:30:52,249 ERROR [stderr] (default task-12) Caused by: java.lang.Throwable: setRollbackOnly called from:
17:30:52,249 ERROR [stderr] (default task-12) at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.setRollbackOnly(TransactionImple.java:339)
17:30:52,253 ERROR [stderr] (default task-12) at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.setRollbackOnly(BaseTransaction.java:159)
17:30:52,257 ERROR [stderr] (default task-12) at com.arjuna.ats.jbossatx.BaseTransactionManagerDelegate.setRollbackOnly(BaseTransactionManagerDelegate.java:143)
17:30:52,257 ERROR [stderr] (default task-12) at org.hibernate.jpa.spi.AbstractEntityManagerImpl.markForRollbackOnly(AbstractEntityManagerImpl.java:1509)
17:30:52,257 ERROR [stderr] (default task-12) at org.hibernate.jpa.spi.AbstractEntityManagerImpl.handlePersistenceException(AbstractEntityManagerImpl.java:1585)
17:30:52,261 ERROR [stderr] (default task-12) at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1693)
17:30:52,261 ERROR [stderr] (default task-12) at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1602)
17:30:52,265 ERROR [stderr] (default task-12) at org.hibernate.jpa.spi.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:1700)
17:30:52,265 ERROR [stderr] (default task-12) at org.hibernate.jpa.spi.AbstractQueryImpl.executeUpdate(AbstractQueryImpl.java:70)
17:30:52,265 ERROR [stderr] (default task-12) at com.intellect.olive.artifacts.APIArtifactImport.deleteserverGroupDtl(APIArtifactImport.java:119)
17:30:52,269 ERROR [stderr] (default task-12) at com.intellect.olive.artifacts.APIArtifactImport.saveservergroupdtl(APIArtifactImport.java:226)
17:30:52,269 ERROR [stderr] (default task-12) at com.intellect.olive.artifacts.APIArtifactImport.saveapiservergroup(APIArtifactImport.java:188)
17:30:52,273 ERROR [stderr] (default task-12) at com.intellect.olive.artifacts.APIArtifactImport.saveapidoc(APIArtifactImport.java:162)
17:30:52,273 ERROR [stderr] (default task-12) at com.intellect.olive.artifacts.APIArtifactImport.importapi(APIArtifactImport.java:135)
17:30:52,273 ERROR [stderr] (default task-12) at Artifact.ServiceCalls.servicecall(ServiceCalls.java:41)
17:30:52,277 ERROR [stderr] (default task-12) ... 30 more