Return-Path: X-Original-To: apmail-openjpa-users-archive@minotaur.apache.org Delivered-To: apmail-openjpa-users-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A11499A3B for ; Thu, 10 Nov 2011 14:23:17 +0000 (UTC) Received: (qmail 40817 invoked by uid 500); 10 Nov 2011 14:23:17 -0000 Delivered-To: apmail-openjpa-users-archive@openjpa.apache.org Received: (qmail 40781 invoked by uid 500); 10 Nov 2011 14:23:17 -0000 Mailing-List: contact users-help@openjpa.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@openjpa.apache.org Delivered-To: mailing list users@openjpa.apache.org Received: (qmail 40773 invoked by uid 99); 10 Nov 2011 14:23:17 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 10 Nov 2011 14:23:17 +0000 X-ASF-Spam-Status: No, hits=2.8 required=5.0 tests=FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS,URI_HEX X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of kwsutter@gmail.com designates 209.85.215.174 as permitted sender) Received: from [209.85.215.174] (HELO mail-ey0-f174.google.com) (209.85.215.174) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 10 Nov 2011 14:23:12 +0000 Received: by eye27 with SMTP id 27so3327496eye.33 for ; Thu, 10 Nov 2011 06:22:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=uSfa8WiTiBi2rCG7Odd61Xbz/UAjuQ5dqP+Hascg2mk=; b=Wrk5ZN6O7m5A1HywMuCzbPJNZkMJlSSS5jd/2FwcpF1MBYFjm50Zfb1/POO0T+IQl1 lidPiRAK1vQDljmX7TAZ8MCftWw58swOAkLAPlsZSRsasUkMXsFJZ+vmzyiG+Ine+nV3 cJfbgTUb4YGhfmuNBrBear6z6q8Co36vUYBkY= Received: by 10.14.4.229 with SMTP id 77mr51397eej.133.1320934971312; Thu, 10 Nov 2011 06:22:51 -0800 (PST) MIME-Version: 1.0 Received: by 10.14.95.130 with HTTP; Thu, 10 Nov 2011 06:22:29 -0800 (PST) In-Reply-To: <1320915449980-6980990.post@n2.nabble.com> References: <1320850642796-6978223.post@n2.nabble.com> <1320852180834-6978287.post@n2.nabble.com> <1320856123952-6978516.post@n2.nabble.com> <1320915449980-6980990.post@n2.nabble.com> From: Kevin Sutter Date: Thu, 10 Nov 2011 08:22:29 -0600 Message-ID: Subject: Re: Constraint violation using OneToOne relationship To: users@openjpa.apache.org Content-Type: multipart/alternative; boundary=0016363ba326bc8baf04b1622370 --0016363ba326bc8baf04b1622370 Content-Type: text/plain; charset=ISO-8859-1 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 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. > --0016363ba326bc8baf04b1622370--