cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r430223 - in /incubator/cayenne/main/trunk/core/cayenne-jpa/src: main/java/org/apache/cayenne/jpa/map/ test/java/org/apache/cayenne/jpa/conf/
Date Thu, 10 Aug 2006 02:56:38 GMT
Author: aadamchik
Date: Wed Aug  9 19:56:37 2006
New Revision: 430223

URL: http://svn.apache.org/viewvc?rev=430223&view=rev
Log:
fixing inclusion of static fields in default persistent properties

Added:
    incubator/cayenne/main/trunk/core/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/conf/MockAnnotatedBean4.java
Modified:
    incubator/cayenne/main/trunk/core/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaClassDescriptor.java
    incubator/cayenne/main/trunk/core/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/conf/EntityMapAnnotationLoaderTest.java
    incubator/cayenne/main/trunk/core/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/conf/EntityMapDefaultsProcessor1Test.java

Modified: incubator/cayenne/main/trunk/core/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaClassDescriptor.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaClassDescriptor.java?rev=430223&r1=430222&r2=430223&view=diff
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaClassDescriptor.java
(original)
+++ incubator/cayenne/main/trunk/core/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaClassDescriptor.java
Wed Aug  9 19:56:37 2006
@@ -158,8 +158,14 @@
 
         for (int i = 0; i < fields.length; i++) {
 
+            int modifiers = fields[i].getModifiers();
             // skip transient fields (in a Java sense)
-            if (Modifier.isTransient(fields[i].getModifiers())) {
+            if (Modifier.isTransient(modifiers)) {
+                continue;
+            }
+            
+            // skip static fields
+            if (Modifier.isStatic(modifiers)) {
                 continue;
             }
 

Modified: incubator/cayenne/main/trunk/core/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/conf/EntityMapAnnotationLoaderTest.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/conf/EntityMapAnnotationLoaderTest.java?rev=430223&r1=430222&r2=430223&view=diff
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/conf/EntityMapAnnotationLoaderTest.java
(original)
+++ incubator/cayenne/main/trunk/core/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/conf/EntityMapAnnotationLoaderTest.java
Wed Aug  9 19:56:37 2006
@@ -82,7 +82,7 @@
 
         JpaBasic a2 = entity.getAttributes().getBasicAttribute("attribute2");
         assertTrue(a2.isLob());
-        
+
         JpaBasic a3 = entity.getAttributes().getBasicAttribute("attribute3");
         assertTrue(a3.isLob());
     }

Modified: incubator/cayenne/main/trunk/core/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/conf/EntityMapDefaultsProcessor1Test.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/conf/EntityMapDefaultsProcessor1Test.java?rev=430223&r1=430222&r2=430223&view=diff
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/conf/EntityMapDefaultsProcessor1Test.java
(original)
+++ incubator/cayenne/main/trunk/core/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/conf/EntityMapDefaultsProcessor1Test.java
Wed Aug  9 19:56:37 2006
@@ -36,13 +36,32 @@
 
         // apply defaults
         new EntityMapDefaultsProcessor().applyDefaults(context);
-        
+
         JpaEntityMap map = context.getEntityMap();
         JpaEntity entity = map.entityForClass(MockAnnotatedBeanVersion.class);
         assertNotNull(entity);
-        
+
         JpaVersion v = entity.getAttributes().getVersionAttribute("attribute1");
         assertNotNull(v);
         assertNotNull(v.getColumn());
+    }
+
+    public void testStaticFields() throws Exception {
+
+        EntityMapLoaderContext context = new EntityMapLoaderContext(
+                new MockPersistenceUnitInfo());
+        EntityMapAnnotationLoader loader = new EntityMapAnnotationLoader(context);
+        loader.loadClassMapping(MockAnnotatedBean4.class);
+
+        // apply defaults
+        new EntityMapDefaultsProcessor().applyDefaults(context);
+
+        JpaEntityMap map = context.getEntityMap();
+        assertEquals(1, map.getEntities().size());
+        JpaEntity entity = map.getEntities().iterator().next();
+
+        // testing that static fields are not loaded as persistent
+        assertEquals(1, entity.getAttributes().size());
+        assertEquals(1, entity.getAttributes().getIds().size());
     }
 }

Added: incubator/cayenne/main/trunk/core/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/conf/MockAnnotatedBean4.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/conf/MockAnnotatedBean4.java?rev=430223&view=auto
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/conf/MockAnnotatedBean4.java
(added)
+++ incubator/cayenne/main/trunk/core/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/conf/MockAnnotatedBean4.java
Wed Aug  9 19:56:37 2006
@@ -0,0 +1,33 @@
+/*****************************************************************
+ *   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;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+
+@Entity
+public class MockAnnotatedBean4 {
+
+    public static final String CONSTANT1 = "a";
+
+    public static String CONSTANT2 = "b";
+
+    @Id
+    protected int id;
+}



Mime
View raw message