openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Goodenough <>
Subject Best practice to avoid duplicates on @Column(unique=true)
Date Fri, 19 Jun 2009 21:28:44 GMT
I realise that this is not strickly an OpenJPA problem, rather a more 
general JPA one, but there are experts here who might know the answer.

I have a number of classes which represent tables which have not only
an Id field, but also various other fields which are marked as unique.

When I persist and then try to flush a new object which has a non-unique
value in the object (the user entered bad data) it breaks the transaction
and throws an error.  All of which is quite understandable.

The question is what is the best way to avoid it.  Do I have to build the
checking into the application, or is there a more generic way which I
can use as a validation technique before I try to persist the object.


View raw message