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 14D4DC213 for ; Thu, 7 Jun 2012 19:23:34 +0000 (UTC) Received: (qmail 45071 invoked by uid 500); 7 Jun 2012 19:23:33 -0000 Delivered-To: apmail-openjpa-users-archive@openjpa.apache.org Received: (qmail 45042 invoked by uid 500); 7 Jun 2012 19:23:33 -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 45034 invoked by uid 99); 7 Jun 2012 19:23:33 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 07 Jun 2012 19:23:33 +0000 X-ASF-Spam-Status: No, hits=2.8 required=5.0 tests=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.46 as permitted sender) Received: from [209.85.215.46] (HELO mail-lpp01m010-f46.google.com) (209.85.215.46) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 07 Jun 2012 19:23:28 +0000 Received: by lahd3 with SMTP id d3so905737lah.33 for ; Thu, 07 Jun 2012 12:23:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=2JxgLyORsVOfXumTqMEDUkmGxQHjAEah2STs6EqMbQQ=; b=hQ5I303ReCpiOd47TujcDxNX3oBs67ng0QaVznlbA9M3pEU5t6jghPzTqWq28EVy/X JBJ2uVDqlQYa4ysnqSeIGaLaUtM9JfMd14wENP8vAU4JVDhwAt2jRB9YWAgn+vvFRCgd z29VkB4qanlMaXlDhDzo5HIKGnta0zi/XflDA/40jSkdrxidKWyTgaQpp7VmH5OfIFX9 1QogYaf1UFgWKv9KsuU9B1qagmuZso7nLp6hIhsE475yn60vA3KUQ9noaD3+WAJ6yf2+ TwtSzquzDJekCtl0IhZzJ6dxPVQoc1ARNgKAWVTd0RLAY+3l3SVGUPvh8BzX6C7X8/wd vMVw== Received: by 10.152.135.105 with SMTP id pr9mr3920495lab.37.1339096986732; Thu, 07 Jun 2012 12:23:06 -0700 (PDT) MIME-Version: 1.0 Received: by 10.112.86.133 with HTTP; Thu, 7 Jun 2012 12:22:46 -0700 (PDT) In-Reply-To: <1338938323664-7580216.post@n2.nabble.com> References: <1338938323664-7580216.post@n2.nabble.com> From: Kevin Sutter Date: Thu, 7 Jun 2012 14:22:46 -0500 Message-ID: Subject: Re: Foreign key to Unique Key Not working To: users@openjpa.apache.org Content-Type: multipart/alternative; boundary=f46d0442715636c68704c1e6d05f X-Virus-Checked: Checked by ClamAV on apache.org --f46d0442715636c68704c1e6d05f Content-Type: text/plain; charset=ISO-8859-1 Hi Anu, The JPA spec indicates that this FK to a non-PK relationship is not standard across vendors. From the section on the JoinColumn annotation: *"If the referencedColumnName element is missing, the foreign key is assumed to refer to the primary key of the referenced table. Support for referenced columns that are not primary key columns of the referenced table is optional. Applications that use such mappings will not be portable." * According to the OpenJPA documentation [1], this non-standard join should be supported, but I have not personally tried it. You said that you tried the column reference, but it didn't work.. Was your usage consistent with the documentation? Also, what version of OpenJPA are you using? Good luck, Kevin [1] http://openjpa.apache.org/builds/latest/docs/docbook/manual.html#ref_guide_mapping_notes_nonstdjoins On Tue, Jun 5, 2012 at 6:18 PM, manushka wrote: > Hello, > > I have a db foreign key pointing to a Unique key and not a Primary key of > the referenced table, > Tried column reference but it does not work. > At the time of the insert on the child record, the INSERT statement shows > that it is trying to insert the primary key of the referenced table. > The PK is int where as the unique key is a varchar, so it naturally bombs. > > Is there away to deal with this scenario or it is not valid for JPA/OPEN > JPA via the relationships. > > Regards'- Anu > > -- > View this message in context: > http://openjpa.208410.n2.nabble.com/Foreign-key-to-Unique-Key-Not-working-tp7580216.html > Sent from the OpenJPA Users mailing list archive at Nabble.com. > --f46d0442715636c68704c1e6d05f--