-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: lifecycle event for persistence failure
PostPosted: Wed Jul 30, 2008 4:24 pm 
Newbie

Joined: Wed Jul 30, 2008 3:34 pm
Posts: 1
I have seen several requests for HV to support database uniqeness constraints.

The general response is "roll your own" validator to perform this check as part of the validation. (prior to INSERT/UPDATE)

I see two issues with this.

View validation
Validation can be done in the view layer, and in this case, the database can not be checked (w/o significant overhead).
While it appears possible to address this by depending on injection of the EntityManager via the @PersistenceContext annotation, the validation in the case where the EntityManager == null can only assume the value is valid.

Costs
Such validation is pretty expensive One or more SELECT(s) to verify uniqueness of column(s).
In the above approach, this must be performed before every insert or update.
This is unnecessary, since the database will enforce constraints and throw some flavor of JDBCException.
It is however ugly to determine what constraint was violated based on the PersistenceException.

It would be preferable to only execute such a validator on a failure.

Has there been any thought to allow for validations to be performed on the entity class after the persistence action fails? (and not at all on success?)

In this case, instead of a PersistenceException, the InvalidStateException would be returned to the client.
Would this break the JPA specification?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.