Daryl Stultz on 26/06/09 13:15, wrote:
I am finding that OpenJPA does not handle my unique constraints the way I expect. When I have a nullable column, say a foreign key that is an integer, and it must be unique (if not null), OpenJPA inserts a 0 instead of null, which violates the FK constraint, of course. Currently I am using the unique constraint on the database but omitting it from the entity metadata (and wondering what benefit I might be sacrificing - the manual speaks only of table creation DDL and ordering SQL statements). Is there a way to define a Unique Constraint that allows null?
Presumably you have tried setting the column definition in your metadata to nullable=true and unique=true ?
