openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kevin Sutter <>
Subject Re: Constraint violation using OneToOne relationship
Date Thu, 10 Nov 2011 14:22:29 GMT
Hi Walter,
Unfortunately, I think you have hit upon a short-coming of OpenJPA's
foreign key detection mechanism.  OpenJPA has attempted to detect and
process foreign keys according to the definition and usage of the entities,
but it still has a couple of holes.  There are two means of forcing OpenJPA
to do the right thing...

1)  The use of the SchemaFactory property.  But, as you have found out,
there may be some side effects if OpenJPA determines that the metadata for
your database schema doesn't match exactly what's defined in your object

2)  The use of the OpenJPA-specific ForeignKey annotation [1].  Although
this requires a change to your entity code, this explicit declaration will
tell OpenJPA that a foreign key exists for this relationship and
appropriate ordering of the SQL will take place to avoid the constraint
violations you are experiencing.

In your scenario, I would suggest trying the ForeignKey approach and see if
that doesn't get you up and running.

Also, since it sounds like you are a WebSphere customer, you might want to
follow up with a PMR.  Even though it might be thought of as a "feature
request", at least it would be logged for future consideration.

Thanks and Good Luck,


On Thu, Nov 10, 2011 at 2:57 AM, M. Walter <> wrote:

> This is just unbelievable! As I expected using this property has side
> effects.
> We have boolean fields defined in our database as number(1,0) because
> Oracle
> does not know boolean type. Now we get ArgumentExceptions saying that we
> declare columns that are not compatible with the expected type "bit". These
> errors never showed up before we added the property
> "openjpa.jdbc.SchemaFactory".
> Now what?
> Remove the property and use OneToMany instead of OneToOne relationships
> with
> programmatically limit the number of child elements to one only? This would
> be very awful.
> Are there any other options we have got?
> --
> View this message in context:
> Sent from the OpenJPA Users mailing list archive at

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message