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 model. 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, Kevin [1] http://openjpa.apache.org/builds/apache-openjpa-1.2.3-SNAPSHOT/docs/manual/manual.html#ref_guide_mapping_jpa_fk On Thu, Nov 10, 2011 at 2:57 AM, M. Walter <marc.wal...@sbb.ch> 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: > http://openjpa.208410.n2.nabble.com/Constraint-violation-using-OneToOne-relationship-tp6978223p6980990.html > Sent from the OpenJPA Users mailing list archive at Nabble.com. >