cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r512660 - in /cayenne/main/trunk/framework/cayenne-jpa-unpublished/src: main/java/org/apache/cayenne/jpa/map/ test/java/org/apache/cayenne/jpa/conf/ test/java/org/apache/cayenne/jpa/map/
Date Wed, 28 Feb 2007 08:43:26 GMT
Author: aadamchik
Date: Wed Feb 28 00:43:25 2007
New Revision: 512660

URL: http://svn.apache.org/viewvc?view=rev&rev=512660
Log:
fixing JPA class inspection bug - special properties added by Cayenne enhancer shouldn't be
mistaken for persistence properties

Added:
    cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/test/java/org/apache/cayenne/jpa/conf/MockFieldRegressionBean.java
Modified:
    cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/main/java/org/apache/cayenne/jpa/map/JpaClassDescriptor.java
    cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/test/java/org/apache/cayenne/jpa/map/JpaClassDescriptorTest.java

Modified: cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/main/java/org/apache/cayenne/jpa/map/JpaClassDescriptor.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/main/java/org/apache/cayenne/jpa/map/JpaClassDescriptor.java?view=diff&rev=512660&r1=512659&r2=512660
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/main/java/org/apache/cayenne/jpa/map/JpaClassDescriptor.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/main/java/org/apache/cayenne/jpa/map/JpaClassDescriptor.java
Wed Feb 28 00:43:25 2007
@@ -30,6 +30,8 @@
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
+import org.apache.cayenne.enhancer.EnhancementHelper;
+
 /**
  * Provides information about a class relevant to JPA, such potential persistence fields,
  * etc.
@@ -77,7 +79,7 @@
     public AccessType getAccess() {
         return access;
     }
-    
+
     public void setAccess(AccessType access) {
         this.access = access;
     }
@@ -162,9 +164,14 @@
             if (Modifier.isTransient(modifiers)) {
                 continue;
             }
-            
+
             // skip static fields
             if (Modifier.isStatic(modifiers)) {
+                continue;
+            }
+
+            // skip fields created by Cayenne enhancer
+            if (EnhancementHelper.isGeneratedField(fields[i].getName())) {
                 continue;
             }
 

Added: cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/test/java/org/apache/cayenne/jpa/conf/MockFieldRegressionBean.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/test/java/org/apache/cayenne/jpa/conf/MockFieldRegressionBean.java?view=auto&rev=512660
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/test/java/org/apache/cayenne/jpa/conf/MockFieldRegressionBean.java
(added)
+++ cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/test/java/org/apache/cayenne/jpa/conf/MockFieldRegressionBean.java
Wed Feb 28 00:43:25 2007
@@ -0,0 +1,27 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+package org.apache.cayenne.jpa.conf;
+
+
+public class MockFieldRegressionBean {
+
+    protected String p1;
+    protected transient String p2;
+    protected String $cay_x;
+}

Modified: cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/test/java/org/apache/cayenne/jpa/map/JpaClassDescriptorTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/test/java/org/apache/cayenne/jpa/map/JpaClassDescriptorTest.java?view=diff&rev=512660&r1=512659&r2=512660
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/test/java/org/apache/cayenne/jpa/map/JpaClassDescriptorTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/test/java/org/apache/cayenne/jpa/map/JpaClassDescriptorTest.java
Wed Feb 28 00:43:25 2007
@@ -21,6 +21,7 @@
 
 import junit.framework.TestCase;
 
+import org.apache.cayenne.jpa.conf.MockFieldRegressionBean;
 import org.apache.cayenne.jpa.conf.MockPropertyRegressionBean;
 
 public class JpaClassDescriptorTest extends TestCase {
@@ -38,7 +39,7 @@
         assertEquals("this", JpaClassDescriptor.propertyNameForSetter("setThis"));
     }
 
-    public void testGetMemberDescriptors() throws Exception {
+    public void testGetMemberDescriptorsProperty() throws Exception {
 
         JpaClassDescriptor descriptor = new JpaClassDescriptor(
                 MockPropertyRegressionBean.class);
@@ -51,5 +52,22 @@
 
         assertNotNull(descriptor.getPropertyForMember(MockPropertyRegressionBean.class
                 .getDeclaredMethod("getP3", new Class[] {})));
+    }
+    
+    public void testGetMemberDescriptorsField() throws Exception {
+
+        JpaClassDescriptor descriptor = new JpaClassDescriptor(
+                MockFieldRegressionBean.class);
+        descriptor.setAccess(AccessType.FIELD);
+
+        assertEquals(1, descriptor.getFieldDescriptors().size());
+
+        assertNotNull(descriptor.getPropertyForMember(MockFieldRegressionBean.class
+                .getDeclaredField("p1")));
+
+        assertNull(descriptor.getPropertyForMember(MockFieldRegressionBean.class
+                .getDeclaredField("p2")));
+        assertNull(descriptor.getPropertyForMember(MockFieldRegressionBean.class
+                .getDeclaredField("$cay_x")));
     }
 }



Mime
View raw message