If I recall correctly, the manual says that the @UniqueConstraint is
used to create proper database constraints when OpenJPA creates your
database. Unicity is enforced by database constraints, not by OpenJPA.

Christian


On 10/11/07, Derry Cannon <[EMAIL PROTECTED]> wrote:
> Hey, there!
>
> I've got a fairly simple entity class that includes the following
> column annotation:
>
> @Column(length = 3, unique = true)
> private String officeCode;
>
> However, if I try to persist a new entity using a value for officeCode
> that I know is already in the table, the transaction processes just
> fine.  I deliberately do not have a unique key for the officeCode set
> on the table because I'm trying to let JPA manage my data store as
> much as possible.  I've also tried putting uniqueConstraints on a
> Table annotation like this:
>
> @Table([EMAIL PROTECTED](columnNames={"officeCode"})})
>
> Unfortunately, the table constraint does seem to be getting enforced,
> either.  Has anyone else seen this behavior?  Am I just missing some
> fundamental piece of how the constraints are supposed to work?
>
> Thanks!
> Derry
>

Reply via email to