I have a class where its email field has unique constraint, a page like this:

  @Inject
  private Session session;

  void onActionFromUpdate1() {
      Usr usr = (Usr) session.get(Usr.class, new Long(2));
      usr.setEmail("[EMAIL PROTECTED]");        // email already used by other 
user
  }

  void onActionFromUpdate2() {
      Usr usr = (Usr) session.get(Usr.class, new Long(2));
      usr.setEmail("[EMAIL PROTECTED]");        // email available
  }


if I click update2, which change the email address to a non existing one,
everything works.

if I do following:

click update 1, that will change email address to one already exists,
naturally I got this:

[WARN] JDBCExceptionReporter SQL Error: 1062, SQLState: 23000
[ERROR] JDBCExceptionReporter Duplicate entry '[EMAIL PROTECTED]' for key 2
[ERROR] AbstractFlushingEventListener Could not synchronize database state
with session
org.hibernate.exception.ConstraintViolationException: Could not execute JDBC
batch update
...
Caused by: java.sql.BatchUpdateException: Duplicate entry '[EMAIL PROTECTED]'
for key 2
...
[WARN] PerthreadManager Error invoking listener
[EMAIL PROTECTED]:
Could not execute JDBC batch update
org.hibernate.exception.ConstraintViolationException: Could not execute JDBC
batch update

Click update 2, it will take a long time before the page got refreshed,
error as follow:

WARN] JDBCExceptionReporter SQL Error: 1205, SQLState: 41000
[ERROR] JDBCExceptionReporter Lock wait timeout exceeded; try restarting
transaction
[ERROR] AbstractFlushingEventListener Could not synchronize database state
with session
org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch
update
...
Caused by: java.sql.BatchUpdateException: Lock wait timeout exceeded; try
restarting transaction
        at
com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:1257)

[WARN] PerthreadManager Error invoking listener
[EMAIL PROTECTED]:
Could not execute JDBC batch update
        org.hibernate.exception.GenericJDBCException: Could not execute JDBC 
batch
update
Caused by: java.sql.BatchUpdateException: Lock wait timeout exceeded; try
restarting transaction
        at
com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:1257)
      

Any way to fix this


-- 
View this message in context: 
http://www.nabble.com/T5%3A-proper-handling-of-hibernate-exception--tp15891081p15891081.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to