openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Derry Cannon" <d3r...@gmail.com>
Subject Unique constraint on column not being enforced?
Date Thu, 11 Oct 2007 19:20:52 GMT
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(uniqueConstraints={@UniqueConstraint(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

Mime
View raw message