RE: help with transactions

View: New views
1 Messages — Rating Filter:   Alert me  

RE: help with transactions

by Waldhoff, Rodney :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
Shaun,
 
Can you provide a simple example or unit test that illustrates this?  I'm having trouble understanding exactly what you're trying to do.
 
 - R


From: Shaun O'Hagan [mailto:shaun.ohagan@...]
Sent: Saturday, March 04, 2006 7:56 AM
To: users@...
Subject: help with transactions

Hi,
I'm having problems handling axion as far as consistant handling of unique key exception.
I have a table that has a unique index on an integer field and if I try to insert a load of data with one duplicate key as expected i get an exception
 
java.sql.SQLException: org.axiondb.AxionException: Expected CODE to be unique, found 844465 already.
 at org.axiondb.util.ExceptionConverter.convert(ExceptionConverter.java:74)
 at org.axiondb.util.ExceptionConverter.convert(ExceptionConverter.java:64)
 at org.axiondb.jdbc.AxionConnection.commit(AxionConnection.java:252)
 at org.axiondb.jdbc.AxionConnection.commit(AxionConnection.java:105)
 at com.megatier.invotrac.util.service.jdbc.JDBC_Base.commit(JDBC_Base.java:507)
 at com.megatier.invotrac.data.dataimport.homelessclis.ImportHomelessClis.importData(ImportHomelessClis.java:66)
 at com.megatier.invotrac.data.dataimport.DataImportTask.svc(DataImportTask.java:43)
 at JACE.ASX.Task.run(Task.java:51)
 at java.lang.Thread.run(Thread.java:534)
 
This exception is generated when I call JDBC commit. 
 
If I run the import again I get
 
java.sql.SQLException: Transaction Conflict (org.axiondb.TransactionConflictException: Transaction conflict.)
 at org.axiondb.util.ExceptionConverter.convert(ExceptionConverter.java:72)
 at org.axiondb.jdbc.AxionConnection.commit(AxionConnection.java:250)
 at org.axiondb.jdbc.AxionConnection.commit(AxionConnection.java:105)
 at com.megatier.invotrac.util.service.jdbc.JDBC_Base.commit(JDBC_Base.java:507)
 at com.megatier.invotrac.data.dataimport.homelessclis.ImportHomelessClis.importData(ImportHomelessClis.java:66)
 at com.megatier.invotrac.data.dataimport.DataImportTask.svc(DataImportTask.java:43)
 at JACE.ASX.Task.run(Task.java:51)
 at java.lang.Thread.run(Thread.java:534)
 
If I try and call rollback() instead to handle the 1st exception I get
 
Caused by: java.sql.SQLException: org.axiondb.AxionException: Already committed or rolled back.
 at org.axiondb.util.ExceptionConverter.convert(ExceptionConverter.java:74)
org.axiondb.AxionException: Already committed or rolled back.
 at org.axiondb.util.ExceptionConverter.convert(ExceptionConverter.java:64)
 at org.axiondb.jdbc.AxionConnection.rollback(AxionConnection.java:266)
 at org.axiondb.jdbc.AxionConnection.rollback(AxionConnection.java:109)
 at com.megatier.invotrac.util.service.jdbc.JDBC_Base.rollback(JDBC_Base.java:517)
 
What is the correct way to handle a unique key violation exception in Axion so that the transaction is cleared down and I can start again without having to stop and start the program.
 
I'm using axion 1.0 M3
 
Thanks
Shaun.
 

has notified the sender that this message has been received.