cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r524768 - /cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/main/java/org/apache/cayenne/jpa/conf/EntityMapDefaultsProcessor.java
Date Mon, 02 Apr 2007 11:22:01 GMT
Author: aadamchik
Date: Mon Apr  2 04:22:00 2007
New Revision: 524768

URL: http://svn.apache.org/viewvc?view=rev&rev=524768
Log:
JPA defaults processor code cleanup

Modified:
    cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/main/java/org/apache/cayenne/jpa/conf/EntityMapDefaultsProcessor.java

Modified: cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/main/java/org/apache/cayenne/jpa/conf/EntityMapDefaultsProcessor.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/main/java/org/apache/cayenne/jpa/conf/EntityMapDefaultsProcessor.java?view=diff&rev=524768&r1=524767&r2=524768
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/main/java/org/apache/cayenne/jpa/conf/EntityMapDefaultsProcessor.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/main/java/org/apache/cayenne/jpa/conf/EntityMapDefaultsProcessor.java
Mon Apr  2 04:22:00 2007
@@ -206,42 +206,33 @@
             }
 
             JpaEntity entity = (JpaEntity) path.firstInstanceOf(JpaEntity.class);
-            JpaClassDescriptor descriptor = entity.getClassDescriptor();
-            JpaPropertyDescriptor property = descriptor.getProperty(jpaBasic.getName());
-
-            boolean typeKnown = false;
 
             // process temporal type defaults
-            if (jpaBasic.getTemporal() != null) {
-                typeKnown = true;
-            }
-            else {
+            if (jpaBasic.getTemporal() == null && jpaBasic.getEnumerated() == null)
{
+                JpaClassDescriptor descriptor = entity.getClassDescriptor();
+                JpaPropertyDescriptor property = descriptor.getProperty(jpaBasic
+                        .getName());
+
+                // sanity check
+                if (property == null) {
+                    throw new IllegalStateException("No class property found for name: "
+                            + jpaBasic.getName());
+                }
+
                 if (java.sql.Date.class.isAssignableFrom(property.getType())) {
                     jpaBasic.setTemporal(TemporalType.DATE);
-                    typeKnown = true;
                 }
                 else if (Time.class.isAssignableFrom(property.getType())) {
                     jpaBasic.setTemporal(TemporalType.TIME);
-                    typeKnown = true;
                 }
                 else if (Timestamp.class.isAssignableFrom(property.getType())) {
                     jpaBasic.setTemporal(TemporalType.TIMESTAMP);
-                    typeKnown = true;
                 }
                 else if (Date.class.isAssignableFrom(property.getType())) {
                     jpaBasic.setTemporal(TemporalType.TIMESTAMP);
-                    typeKnown = true;
-                }
-            }
-
-            // process enum type defaults
-            if (!typeKnown) {
-                if (jpaBasic.getEnumerated() != null) {
-                    typeKnown = true;
                 }
                 else if (property.getType().isEnum()) {
                     jpaBasic.setEnumerated(EnumType.ORDINAL);
-                    typeKnown = true;
                 }
             }
 



Mime
View raw message