openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chintan4181 <chintan4...@gmail.com>
Subject Re: @Version for sqlserver "timpstamp" datatype
Date Thu, 14 Apr 2011 14:58:42 GMT
Thanks Mike. I just tried another approach by selecting one datetime field
for versioning. Howerver i am getting below exception. Full details are as
below. can you please advise me what is wrong?

I am trying to implement optimistic locking using JPA. I am using container
manged transaction. 

Loan entity has few other fields and one of the field is annotated with
@version. 
@Column(name = "Loan_Date_Modified") 
@Version 
private Timestamp Loan_Date_Modified; 

In SLSB class i have followign code: 
Loan loan = new Loan(); 
loan.setSomeProperty("newVal"); 

em.lock(loan, LockModeType.OPTIMISTIC_FORCE_INCREMENT); 
em.persist(loan); 

When i run multiple threads at the same time using SOAP UI to check
concurrency, it throws me Lock time out exception instead of
OptimisticLockException. I have doubt whether this is correct implementation
of optmistic lock or not. 

can someone please help? 

Here is excetpion details: 
aused by:  org.apache.openjpa.persistence.PersistenceException: Lock request
time out period exceeded. {prepstmnt 1720673935 
UPDATE Loan 
    SET Loan_Date_Modified = ? 
    WHERE Cert_ID = ? AND Loan_Date_Modified = ? 
[params=(Timestamp) 2011-04-13 09:08:27.166, (int) 5452546, (Timestamp)
2011-04-13 09:08:24.01]} [code=1222, state=S00051] 
FailedObject: com.foo.jpa.entities.Loan-5452546 
        at
org.apache.openjpa.jdbc.sql.DBDictionary.narrow(DBDictionary.java:4827) 
        at
org.apache.openjpa.jdbc.sql.DBDictionary.newStoreException(DBDictionary.java:4787) 
        at
org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:136) 
        at
org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:78) 
        at
org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flushAndUpdate(PreparedStatementManagerImpl.java:143)

        at
org.apache.openjpa.jdbc.kernel.BatchingPreparedStatementManagerImpl.flushAndUpdate(BatchingPreparedStatementManagerImpl.java:81)

        at
com.ibm.ws.persistence.jdbc.kernel.PreparedStatementManagerImpl.flushAndUpdate(PreparedStatementManagerImpl.java:47)

        at
org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flushInternal(PreparedStatementManagerImpl.java:99)

        at
org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flush(PreparedStatementManagerImpl.java:87)

        at
org.apache.openjpa.jdbc.kernel.ConstraintUpdateManager.flush(ConstraintUpdateManager.java:550)

        at
org.apache.openjpa.jdbc.kernel.ConstraintUpdateManager.flush(ConstraintUpdateManager.java:107)

        at
org.apache.openjpa.jdbc.kernel.BatchingConstraintUpdateManager.flush(BatchingConstraintUpdateManager.java:59)

        at
org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.flush(AbstractUpdateManager.java:103)

        at
org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.flush(AbstractUpdateManager.java:76)

        at
org.apache.openjpa.jdbc.kernel.JDBCStoreManager.flush(JDBCStoreManager.java:751) 
        at
org.apache.openjpa.kernel.DelegatingStoreManager.flush(DelegatingStoreManager.java:131) 
        ... 49 more 
Caused by: org.apache.openjpa.lib.jdbc.ReportingSQLException: Lock request
time out period exceeded. {prepstmnt 1720673935 
UPDATE Loan 
    SET Loan_Date_Modified = ? 
    WHERE Prmary_ID = ? AND Loan_Date_Modified = ? 
[params=(Timestamp) 2011-04-13 09:08:27.166, (int) 5452546, (Timestamp)
2011-04-13 09:08:24.01]} [code=1222, state=S00051] 
        at
org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.wrap(LoggingConnectionDecorator.java:257)

        at
org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.wrap(LoggingConnectionDecorator.java:233)

        at
org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.access$1000(LoggingConnectionDecorator.java:70)

        at
org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator$LoggingConnection$LoggingPreparedStatement.executeUpdate(LoggingConnectionDecorator.java:1079)

        at
org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:285)

        at
org.apache.openjpa.jdbc.kernel.JDBCStoreManager$CancelPreparedStatement.executeUpdate(JDBCStoreManager.java:1722)

        at
org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.executeUpdate(PreparedStatementManagerImpl.java:267)

        at
org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flushAndUpdate(PreparedStatementManagerImpl.java:118)

        ... 60 more 
---- Begin backtrace for Nested Throwables 
com.microsoft.sqlserver.jdbc.SQLServerException: Lock request time out
period exceeded. 
        at
com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:197)

        at
com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1493)

        at
com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(SQLServerPreparedStatement.java:390)

        at
com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(SQLServerPreparedStatement.java:340)

        at
com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:4575) 
        at
com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1400)

        at
com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:179)

        at
com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:154)

        at
com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeUpdate(SQLServerPreparedStatement.java:308)

        at
com.ibm.ws.rsadapter.jdbc.WSJdbcPreparedStatement.pmiExecuteUpdate(WSJdbcPreparedStatement.java:1172)

        at
com.ibm.ws.rsadapter.jdbc.WSJdbcPreparedStatement.executeUpdate(WSJdbcPreparedStatement.java:813)

        at
org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:285)

        at
org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator$LoggingConnection$LoggingPreparedStatement.executeUpdate(LoggingConnectionDecorator.java:1077)

        at
org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:285)

        at
org.apache.openjpa.jdbc.kernel.JDBCStoreManager$CancelPreparedStatement.executeUpdate(JDBCStoreManager.java:1722)

        at
org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.executeUpdate(PreparedStatementManagerImpl.java:267)

        at
org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flushAndUpdate(PreparedStatementManagerImpl.java:118)

        at
org.apache.openjpa.jdbc.kernel.BatchingPreparedStatementManagerImpl.flushAndUpdate(BatchingPreparedStatementManagerImpl.java:81)

        at
com.ibm.ws.persistence.jdbc.kernel.PreparedStatementManagerImpl.flushAndUpdate(PreparedStatementManagerImpl.java:47)

        at
org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flushInternal(PreparedStatementManagerImpl.java:99)

        at
org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flush(PreparedStatementManagerImpl.java:87)

        at
org.apache.openjpa.jdbc.kernel.ConstraintUpdateManager.flush(ConstraintUpdateManager.java:550)

        at
org.apache.openjpa.jdbc.kernel.ConstraintUpdateManager.flush(ConstraintUpdateManager.java:107)

        at
org.apache.openjpa.jdbc.kernel.BatchingConstraintUpdateManager.flush(BatchingConstraintUpdateManager.java:59)

        at
org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.flush(AbstractUpdateManager.java:103)

        at
org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.flush(AbstractUpdateManager.java:76)

        at
org.apache.openjpa.jdbc.kernel.JDBCStoreManager.flush(JDBCStoreManager.java:751) 
        at
org.apache.openjpa.kernel.DelegatingStoreManager.flush(DelegatingStoreManager.java:131) 
        at org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:2139) 
        at
org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java:2037) 
        at
org.apache.openjpa.kernel.BrokerImpl.beforeCompletion(BrokerImpl.java:1955) 
        at
com.ibm.ws.uow.ComponentContextSynchronizationWrapper.beforeCompletion(ComponentContextSynchronizationWrapper.java:65)

        at
com.ibm.tx.jta.RegisteredSyncs.coreDistributeBefore(RegisteredSyncs.java:289) 
        at
com.ibm.ws.tx.jta.RegisteredSyncs.distributeBefore(RegisteredSyncs.java:150) 
        at
com.ibm.ws.tx.jta.TransactionImpl.prePrepare(TransactionImpl.java:2312) 
        at
com.ibm.ws.tx.jta.TransactionImpl.stage1CommitProcessing(TransactionImpl.java:533) 
        at
com.ibm.tx.jta.TransactionImpl.processCommit(TransactionImpl.java:978) 
        at com.ibm.tx.jta.TransactionImpl.commit(TransactionImpl.java:913) 
        at
com.ibm.ws.tx.jta.TranManagerImpl.commit(TranManagerImpl.java:377) 
        at com.ibm.tx.jta.TranManagerSet.commit(TranManagerSet.java:161) 
        at com.ibm.ejs.csi.TranStrategy.commit(TranStrategy.java:927) 
        at com.ibm.ejs.csi.TranStrategy.postInvoke(TranStrategy.java:230) 
        at
com.ibm.ejs.csi.TransactionControlImpl.postInvoke(TransactionControlImpl.java:570) 
        at
com.ibm.ejs.container.EJSContainer.postInvoke(EJSContainer.java:4558) 
        at
com.ibm.ejs.container.WSEJBWrapper.ejbPostInvoke(WSEJBWrapper.java:253) 
        at
com.ibm.ws.websvcs.server.WSInvocationListener.responseReady(WSInvocationListener.java:369)

        at
com.ibm.ws.websvcs.server.WSInvocationListener.notify(WSInvocationListener.java:89) 
        at
org.apache.axis2.jaxws.server.EndpointController.responseReady(EndpointController.java:672)

        at
org.apache.axis2.jaxws.server.EndpointController.handleResponse(EndpointController.java:404)

        at
org.apache.axis2.jaxws.server.EndpointController.invoke(EndpointController.java:128) 
        at
org.apache.axis2.jaxws.server.JAXWSMessageReceiver.receive(JAXWSMessageReceiver.java:159)

        at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:188) 
        at
org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:275)

        at
com.ibm.ws.websvcs.transport.http.WASAxis2Servlet.doPost(WASAxis2Servlet.java:1351) 
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:738) 
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:831) 
        at
com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1655) 
        at
com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:937) 
        at
com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:500) 
        at
com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178)

        at
com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:91)

        at
com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:864) 
        at
com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1583) 
        at
com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:186) 
        at
com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:455)

        at
com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:384)

        at
com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:272) 
        at
com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)

        at
com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)

        at
com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)

        at
com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217) 
        at
com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161) 
        at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138) 
        at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204) 
        at
com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775) 
        at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905) 
        at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1550) 



--
View this message in context: http://openjpa.208410.n2.nabble.com/Version-for-sqlserver-timpstamp-datatype-tp6267241p6273135.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Mime
View raw message