• Post Reply Bookmark Topic Watch Topic
  • New Topic

Hibernate Validation on Update  RSS feed

Annie Harris
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I have J2EE appplication running on JBoss 4.0.3. It is using a Hibernate MBean & using a Session bean to manage the hibernate transactions.

When I create a new record, the database constraints (e.g. unique name) can be caught & dealt with (with the purpose of presenting a readable message to the user):

try { session.save(newRecord); }
catch (ConstraintViolationException e) { // deal with it }

When I update an existing record, the exception isn't caught in the same manner:

try { session.update(existingRecord); }
catch (ConstraintViolationException e) { // exception not thrown }

It is only when the record is persisted to the DB that org.jboss.tm.JBossRollbackException with a nested throwable: (org.hibernate.exception.ConstraintViolationException) is thrown.

How do I can configure hibernate to validate the constraints before it reaches the db so that I can deal with the update save & update in the same manner?

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!