incubator-isis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ke...@apache.org
Subject svn commit: r1167598 - /incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/jdbc/AbstractJdbcMultiFieldMapping.java
Date Sat, 10 Sep 2011 20:08:29 GMT
Author: kevin
Date: Sat Sep 10 20:08:29 2011
New Revision: 1167598

URL: http://svn.apache.org/viewvc?rev=1167598&view=rev
Log:
ISIS-121: Minor cleanup - DRY: re-used repeated code and possibly improved re-use of the AdapterManager.

Modified:
    incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/jdbc/AbstractJdbcMultiFieldMapping.java

Modified: incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/jdbc/AbstractJdbcMultiFieldMapping.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/jdbc/AbstractJdbcMultiFieldMapping.java?rev=1167598&r1=1167597&r2=1167598&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/jdbc/AbstractJdbcMultiFieldMapping.java
(original)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/jdbc/AbstractJdbcMultiFieldMapping.java
Sat Sep 10 20:08:29 2011
@@ -26,11 +26,13 @@ import org.apache.isis.runtimes.dflt.obj
 import org.apache.isis.runtimes.dflt.objectstores.sql.Results;
 import org.apache.isis.runtimes.dflt.objectstores.sql.Sql;
 import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContext;
+import org.apache.isis.runtimes.dflt.runtime.system.persistence.AdapterManager;
 
 public abstract class AbstractJdbcMultiFieldMapping extends AbstractJdbcFieldMapping {
     private final int columnCount;
     private final String[] types;
     private final String[] columnNames;
+    private final AdapterManager adapterManager;
 
     /**
      * 
@@ -56,6 +58,9 @@ public abstract class AbstractJdbcMultiF
         columnNames = new String[columnCount];
         columnNames[0] = Sql.sqlFieldName(fieldName + "1");
         columnNames[1] = Sql.sqlFieldName(fieldName + "2");
+
+        adapterManager = IsisContext.getPersistenceSession().getAdapterManager();
+
     }
 
     @Override
@@ -108,11 +113,7 @@ public abstract class AbstractJdbcMultiF
 
     @Override
     public void appendWhereClause(final DatabaseConnector connector, final StringBuffer sql,
final ObjectAdapter object) {
-        final ObjectAdapter fieldValue = field.get(object);
-        final Object o = (fieldValue == null) ? null : fieldValue.getObject();
-        for (int i = 0; i < columnCount; i++) {
-            appendEqualsClause(connector, i, sql, o, "=");
-        }
+        appendUpdateValues(connector, sql, object);
     }
 
     private void appendEqualsClause(final DatabaseConnector connector, final int index, final
StringBuffer sql,
@@ -132,7 +133,8 @@ public abstract class AbstractJdbcMultiF
     public ObjectAdapter setFromDBColumn(final Results results, final String columnName,
final ObjectAssociation field) {
         ObjectAdapter restoredValue;
         final Object objectValue = getObjectFromResults(results);
-        restoredValue = IsisContext.getPersistenceSession().getAdapterManager().adapterFor(objectValue);
+        restoredValue = adapterManager.adapterFor(objectValue); // NOTE: If this fails, then
fetch back the declaration
+                                                                // from the constructor to
here.
         return restoredValue;
     }
 



Mime
View raw message