Return-Path: X-Original-To: apmail-openjpa-commits-archive@www.apache.org Delivered-To: apmail-openjpa-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 644876ED4 for ; Thu, 30 Jun 2011 15:52:34 +0000 (UTC) Received: (qmail 60312 invoked by uid 500); 30 Jun 2011 15:52:34 -0000 Delivered-To: apmail-openjpa-commits-archive@openjpa.apache.org Received: (qmail 60251 invoked by uid 500); 30 Jun 2011 15:52:33 -0000 Mailing-List: contact commits-help@openjpa.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@openjpa.apache.org Delivered-To: mailing list commits@openjpa.apache.org Received: (qmail 60242 invoked by uid 99); 30 Jun 2011 15:52:33 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 30 Jun 2011 15:52:33 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 30 Jun 2011 15:52:32 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 19DB4238890D for ; Thu, 30 Jun 2011 15:52:12 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1141583 - in /openjpa/trunk/openjpa-persistence/src/main: java/org/apache/openjpa/persistence/meta/MetamodelImpl.java resources/org/apache/openjpa/persistence/meta/localizer.properties Date: Thu, 30 Jun 2011 15:52:12 -0000 To: commits@openjpa.apache.org From: ppoddar@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110630155212.19DB4238890D@eris.apache.org> Author: ppoddar Date: Thu Jun 30 15:52:11 2011 New Revision: 1141583 URL: http://svn.apache.org/viewvc?rev=1141583&view=rev Log: OPENJPA-2024: Ignore non-canonical fields during metamodel assignment Modified: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/meta/MetamodelImpl.java openjpa/trunk/openjpa-persistence/src/main/resources/org/apache/openjpa/persistence/meta/localizer.properties Modified: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/meta/MetamodelImpl.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/meta/MetamodelImpl.java?rev=1141583&r1=1141582&r2=1141583&view=diff ============================================================================== --- openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/meta/MetamodelImpl.java (original) +++ openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/meta/MetamodelImpl.java Thu Jun 30 15:52:11 2011 @@ -308,6 +308,9 @@ public class MetamodelImpl implements Me for (Field mf : mfields) { try { ParameterizedType mfType = getParameterziedType(mf); + if (mfType == null) { + continue; + } Attribute f = type.getAttribute(mf.getName()); Class fClass = f.getJavaType(); java.lang.reflect.Type[] args = mfType.getActualTypeArguments(); @@ -334,12 +337,18 @@ public class MetamodelImpl implements Me /** * Gets the parameterized type of the given field after validating. + * + * @return the field's type as a parameterized type. If the field + * is not parameterized type (that can happen for non-canonical + * metamodel or weaving process introducing synthetic fields), + * returns null. */ ParameterizedType getParameterziedType(Field mf) { java.lang.reflect.Type t = mf.getGenericType(); if (t instanceof ParameterizedType == false) { - throw new IllegalStateException(_loc.get("meta-field-not-param", + repos.getLog().warn(_loc.get("meta-field-not-param", mf.getDeclaringClass(), mf.getName(), toTypeName(t)).getMessage()); + return null; } ParameterizedType mfType = (ParameterizedType)t; java.lang.reflect.Type[] args = mfType.getActualTypeArguments(); @@ -367,9 +376,9 @@ public class MetamodelImpl implements Me java.lang.reflect.Type[] args = pType.getActualTypeArguments(); StringBuilder tmp = new StringBuilder(pType.getRawType().toString()); for (int i = 0; i < args.length; i++) { - tmp.append((i == 0) ? "<" : ","); + tmp.append((i == 0) ? '<' : ','); tmp.append(toTypeName(args[i])); - tmp.append((i == args.length-1) ? ">" : ""); + if (i == args.length-1) tmp.append('>'); } return tmp.toString(); } Modified: openjpa/trunk/openjpa-persistence/src/main/resources/org/apache/openjpa/persistence/meta/localizer.properties URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/resources/org/apache/openjpa/persistence/meta/localizer.properties?rev=1141583&r1=1141582&r2=1141583&view=diff ============================================================================== --- openjpa/trunk/openjpa-persistence/src/main/resources/org/apache/openjpa/persistence/meta/localizer.properties (original) +++ openjpa/trunk/openjpa-persistence/src/main/resources/org/apache/openjpa/persistence/meta/localizer.properties Thu Jun 30 15:52:11 2011 @@ -53,7 +53,9 @@ mmg-bad-log: Log level specified in -Alo meta-class-no-anno: Meta class "{0}" registered for "{1}" is not annotated \ with "{2}" annotation. meta-field-mismatch: The field "{0}" in meta class "{1}" is of type "{2}" \ - which does not match the persistent property type "{3}". + which does not match the persistent property type "{3}". +meta-field-not-param: Encountered field " {2} {1}" in "{0}". This field is \ + not recognized as canonical field. Ignoring. type-wrong-category:"{0}" categorized as "{1}" should be a "{2}" mmg-asl-header: Licensed to the Apache Software Foundation (ASF) under one \ or more contributor license agreements. See the NOTICE file distributed \