Return-Path: Delivered-To: apmail-openjpa-users-archive@minotaur.apache.org Received: (qmail 35413 invoked from network); 22 Oct 2009 14:34:04 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 22 Oct 2009 14:34:04 -0000 Received: (qmail 65208 invoked by uid 500); 22 Oct 2009 14:34:04 -0000 Delivered-To: apmail-openjpa-users-archive@openjpa.apache.org Received: (qmail 65140 invoked by uid 500); 22 Oct 2009 14:34:04 -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 65129 invoked by uid 99); 22 Oct 2009 14:34:04 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 22 Oct 2009 14:34:04 +0000 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of ljnelson@gmail.com designates 209.85.219.219 as permitted sender) Received: from [209.85.219.219] (HELO mail-ew0-f219.google.com) (209.85.219.219) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 22 Oct 2009 14:33:55 +0000 Received: by ewy19 with SMTP id 19so7856583ewy.28 for ; Thu, 22 Oct 2009 07:33:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type; bh=WGBD5+sgj4Q5v4LRmtkTSUUyIIv7BJvVf9QEGjLGcmM=; b=jgNwNCIvDRgUI5phqY1G7iJgF/ezor3MoO3RJEbnXK5FPUM3iJqta5LKJpqeSsoEy9 uSyf8adbzu3RKx2cS11z4dtlGUy6RsrT1dAv0agAxXoQ5fFO3XazaBGLdzrW+LMojTf2 oKQI+7N1yygs9hAXo2MOQ9pJDqlvwjIlmDLNg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=lvdv8KvRUfKNpNQMrj5HjqmUuf++CTOmRq2XAzuqiUVW0b424/R0HHuetGfluDe32U LGhwB7OCtVGXDBlbUoKxLsINbDKKx7p29+hRqUD3eGBVzeWlEVvMu9qiwutP9MnSEnuC SdS2pPLmuuDAVhEN+0EFzIDGnlHhKF7vl/0f8= MIME-Version: 1.0 Received: by 10.216.87.147 with SMTP id y19mr3248648wee.12.1256222015594; Thu, 22 Oct 2009 07:33:35 -0700 (PDT) Date: Thu, 22 Oct 2009 10:33:35 -0400 Message-ID: <2c0ebf0c0910220733n5cb6be0ck8af84e4f9f2aa04c@mail.gmail.com> Subject: Deducing a primary key, customizing in ReverseCustomizer? From: Laird Nelson To: users@openjpa.apache.org Content-Type: multipart/alternative; boundary=0016e6d64514ffa143047686fa06 X-Virus-Checked: Checked by ClamAV on apache.org --0016e6d64514ffa143047686fa06 Content-Type: text/plain; charset=ISO-8859-1 Before I spend a lot of time going down the wrong path, I thought I'd ask the (rather silent these days?) users list what the best approach is. I work for a company that has a 30 year old database that chose for all sorts of reasons to have many of its tables defined without primary keys. Of any kind. What such tables *do* have are unique indices. For the sake of this argument, assume that for various valid and invalid reasons we cannot go back and add true primary keys. I am actually working on seeing if this is possible--it's quite obviously the most appropriate solution. But, failing that, a human being can glance at the DDL for these tables, and, being familiar with some naming conventions, can determine which of potentially many unique indices is the "real" one that is treated by the rest of the application as that table's primary key. My challenge is to see if I can perform the same analysis from within the bowels of an OpenJPA ReverseCustomizer and so cause the ReverseMappingTool to spit out JPA entities with @Id annotations, even in the case where the tool, unassisted, could not discover any primary key information. My initial thought was to perform this analysis within the customize(FieldMapping) method. Then I saw the Javadoc for FieldMapping and realized it had somewhere around 100 methods (by inheritance). Egad. Before I begin the long, slow process of understanding these hundreds of methods, does anyone know if at customize(FieldMapping)-time I have access to: * The names of unique indices found so far (I presume yes) * The ability to "step in" and inform the ReverseMappingTool that the field mapping under consideration is to be output as a primary key, even though that information was not present in the database ...? If I don't have these abilities, then this is the wrong path to go down. Thank you, Laird --0016e6d64514ffa143047686fa06--