Announcement Announcement Module
Collapse
No announcement yet.
[Roo + GWT] Duplicate entry 'xxxx' for key 'name' (JDBCExceptionReporter) Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • [Roo + GWT] Duplicate entry 'xxxx' for key 'name' (JDBCExceptionReporter)

    Hello,

    In application made with Roo (1.2.0.M1) + GWT, when client fire the creation or the update of an entity with ConstraintViolation, the Receiver got an onConstraintViolation call.

    It's ok with field size, notnull constraints but not unique constraint.

    With unique constraint, annotate with "@Column(unique = true)", Receiver get a "onSuccess(Void void)" call with no way to know that the persistence is in error.

    Is there a way to get an onConstraintViolation in case of Duplicate entry DB error ?

    Thanks.
    Pascal.

  • #2
    JSR303 is not implementing uniqueness validation

    OK it's not as simple as this because JSR303 is not implementing uniqueness validation.
    Why : because between the check and the persist call someone else can persist a similar entity and make you get a "Duplicate entry" error.

    What can we do ?
    Create a JSR 303 style unique value annotation checking there is no table entry with same value.

    This is a good solution ?
    No, there is no real good solution except getting a lock on the table between check and persist, but seem to be a performance bad solution.

    So ?
    It's better than nothing. You will be in trouble only in case of double persist entity with same unique values. Depend and your application but seem to be rare.

    Links about creating a JSR 303 style unique value annotation :
    http://omgo.wordpress.com/2009/10/25...-spring-3-mvc/
    https://vaadin.com/forum/-/message_b...message/471658
    http://www.mkyong.com/spring-mvc/spr...valid-example/

    If you have other examples, feel free to give it !

    --
    Pascoual.

    Comment

    Working...
    X