Win a copy of Penetration Testing Basics this week in the Security forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate Validation on Update

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 {; }
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 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?

Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic