db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arm...@apache.org
Subject svn commit: r422228 [2/2] - in /db/ojb/trunk: ./ src/java/org/apache/ojb/broker/accesslayer/ src/java/org/apache/ojb/broker/accesslayer/conversions/ src/java/org/apache/ojb/broker/accesslayer/sql/
Date Sat, 15 Jul 2006 14:17:30 GMT
Modified: db/ojb/trunk/src/java/org/apache/ojb/broker/accesslayer/conversions/StringList2VarcharFieldConversion.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/java/org/apache/ojb/broker/accesslayer/conversions/StringList2VarcharFieldConversion.java?rev=422228&r1=422227&r2=422228&view=diff
==============================================================================
--- db/ojb/trunk/src/java/org/apache/ojb/broker/accesslayer/conversions/StringList2VarcharFieldConversion.java
(original)
+++ db/ojb/trunk/src/java/org/apache/ojb/broker/accesslayer/conversions/StringList2VarcharFieldConversion.java
Sat Jul 15 07:17:29 2006
@@ -15,119 +15,22 @@
  * limitations under the License.
  */
 
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.commons.lang.StringUtils;
 
 /**
  * This implementation of the {@link FieldConversion} interface converts
  * between a {@link java.util.List} of {@link java.lang.String} objects and a database
  * <em>varchar</em> field.
  * <br/>
- * Strings may not contain "#" as this is used as separator.
+ * Strings may not contain <em>"#"</em> (at the beginning and end of a string)
as this is
+ * used as separator.
+ * Additionally this implementation use keywords for "blank string" and 'null' list entires,
thus Strings may
+ * not contain keywords <em>"+.EmPtY.+"</em> and <em>"+.NuLl.+"</em>.
  *
- * @author Guillaume Nodet
  * @version $Id$
  */
-public class StringList2VarcharFieldConversion implements FieldConversion
+public class StringList2VarcharFieldConversion extends AbstractList2VarcharConversion
 {
-
-    private static final String NULLVALUE = "#NULL#";
-    private static final String EMPTYCOLLEC = "#EMTPY#";
-
     public StringList2VarcharFieldConversion()
     {
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.ojb.broker.accesslayer.conversions.FieldConversion#javaToSql(java.lang.Object)
-     */
-    public Object javaToSql(Object source) throws ConversionException
-    {
-
-        if (source == null)
-        {
-            return NULLVALUE;
-        }
-
-        try
-        {
-            List stringList = (List) source;
-            if (stringList.isEmpty())
-            {
-                return NULLVALUE;
-            }
-
-            StringBuffer result = new StringBuffer();
-            for (int i = 0; i < stringList.size(); i++)
-            {
-                String newSt = (String) stringList.get(i);
-                // introduced in JDK 1.4, replace with commons-lang
-                // newSt = newSt.replaceAll("#", "##");
-                newSt = StringUtils.replace(newSt, "#", "##");
-                if (i > 0)
-                {
-                    result.append("#");
-                }
-                result.append(newSt);
-            }
-            return result.toString();
-        }
-        catch (ClassCastException e)
-        {
-            throw new ConversionException("Object is not a List of String it is a"
-                    + source.getClass().getName());
-        }
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.ojb.broker.accesslayer.conversions.FieldConversion#sqlToJava(java.lang.Object)
-     */
-    public Object sqlToJava(Object source) throws ConversionException
-    {
-        if (source == null)
-        {
-            return null;
-        }
-        if (source.toString().equals(NULLVALUE))
-        {
-            return null;
-        }
-        if (source.toString().equals(EMPTYCOLLEC))
-        {
-            return new ArrayList();
-        }
-        List v = new ArrayList();
-        StringBuffer input = new StringBuffer();
-        StringBuffer newString = new StringBuffer();
-        int pos = 0;
-        int length;
-
-        input.append(source.toString());
-        length = input.length();
-        while (pos < length)
-        {
-            if (input.charAt(pos) != '#')
-            {
-                newString.append(input.charAt(pos));
-            }
-            else
-            {
-                if (input.charAt(pos + 1) != '#')
-                {
-                    v.add(newString.toString());
-                    newString = new StringBuffer();
-                }
-                else
-                {
-                    newString.append('#');
-                    ++pos;
-                }
-            }
-            ++pos;
-        }
-        v.add(newString.toString());
-        return v;
     }
 }

Modified: db/ojb/trunk/src/java/org/apache/ojb/broker/accesslayer/conversions/StringVector2VarcharFieldConversion.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/java/org/apache/ojb/broker/accesslayer/conversions/StringVector2VarcharFieldConversion.java?rev=422228&r1=422227&r2=422228&view=diff
==============================================================================
--- db/ojb/trunk/src/java/org/apache/ojb/broker/accesslayer/conversions/StringVector2VarcharFieldConversion.java
(original)
+++ db/ojb/trunk/src/java/org/apache/ojb/broker/accesslayer/conversions/StringVector2VarcharFieldConversion.java
Sat Jul 15 07:17:29 2006
@@ -16,108 +16,33 @@
  */
 
 import java.util.Vector;
+import java.util.List;
 
 /**
  * Converts a Vector of string elements back and forth from a database varchar field
  * Strings may not contain "#" as this is used as separator.
- * This class maybe useful if it's important to have the string vector stored in a 
+ * This class maybe useful if it's important to have the string vector stored in a
  * human readable form that allows editing.
+ *  <br/>
+ * Strings may not contain <em>"#"</em> (at the beginning and end of a string)
as this is
+ * used as separator.
+ * Additionally this implementation use keywords for "blank string" and 'null' list entires,
thus Strings may
+ * not contain keywords <em>"+.EmPtY.+"</em> and <em>"+.NuLl.+"</em>.
+ *
  * @see Object2ByteArrFieldConversion uses Java serialization and is not suited for
- * this purpose. 
- * 
- * @author  sschloesser  mailto: stefan.schl@gmx.de 
+ * this purpose.
  * @version $Id$
  */
-public class StringVector2VarcharFieldConversion implements FieldConversion
+public class StringVector2VarcharFieldConversion extends AbstractList2VarcharConversion
 {
 
-    private static final String NULLVALUE = "#NULL#";
-    private static final String EMPTYCOLLEC = "#EMTPY#";
-    private static final String SEPARATOR = "#";
-
     /** Creates a new instance of StringVector2VarcharFieldConversion */
     public StringVector2VarcharFieldConversion()
     {
     }
 
-    public Object javaToSql(Object obj)
-        throws org.apache.ojb.broker.accesslayer.conversions.ConversionException
+    protected List newList()
     {
-
-        if (obj == null)
-        {
-            return NULLVALUE;
-        }
-
-        if (!(obj instanceof Vector))
-        {
-            throw new ConversionException(
-                "Object is not a vector it is a" + obj.getClass().getName());
-        }
-
-        Vector v = (Vector) obj;
-        if (v.size() == 0)
-        {
-            return EMPTYCOLLEC;
-        }
-
-        StringBuffer result = new StringBuffer();
-        for (int i = 0; i < v.size(); i++)
-        {
-            String newSt = v.get(i).toString();
-            if (newSt.indexOf(SEPARATOR) >= 0)
-            {
-                throw new ConversionException(
-                    "An entry in the Vector contains the forbidden "
-                        + SEPARATOR
-                        + " character used to separate the strings on the DB");
-            }
-            result.append(newSt);
-            result.append(SEPARATOR);
-        }
-        return result.toString();
-    }
-
-    public Object sqlToJava(Object obj)
-        throws org.apache.ojb.broker.accesslayer.conversions.ConversionException
-    {
-
-        if (obj == null)
-        {
-            return null;
-        }
-        if (obj.toString().equals(NULLVALUE))
-        {
-            return null;
-        }
-        if (obj.toString().equals(EMPTYCOLLEC))
-        {
-            return new Vector();
-        }
-
-        Vector v = new Vector();
-        String input = obj.toString();
-        int pos = input.indexOf(SEPARATOR);
-
-        while (pos >= 0)
-        {
-            if (pos == 0)
-            {
-                v.add("");
-            }
-            else
-            {
-                v.add(input.substring(0, pos));
-            }
-
-            if (pos + 1 > input.length()) //# at end causes outof bounds
-            {
-                break;
-            }
-
-            input = input.substring(pos + 1, input.length());
-            pos = input.indexOf(SEPARATOR);
-        }
-        return v;
+        return new Vector();
     }
 }

Modified: db/ojb/trunk/src/java/org/apache/ojb/broker/accesslayer/conversions/TimeList2VarcharFieldConversion.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/java/org/apache/ojb/broker/accesslayer/conversions/TimeList2VarcharFieldConversion.java?rev=422228&r1=422227&r2=422228&view=diff
==============================================================================
--- db/ojb/trunk/src/java/org/apache/ojb/broker/accesslayer/conversions/TimeList2VarcharFieldConversion.java
(original)
+++ db/ojb/trunk/src/java/org/apache/ojb/broker/accesslayer/conversions/TimeList2VarcharFieldConversion.java
Sat Jul 15 07:17:29 2006
@@ -16,108 +16,47 @@
  */
 
 import java.sql.Time;
-import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.commons.lang.StringUtils;
-
 /**
  * This implementation of the {@link FieldConversion} interface converts
  * between a {@link java.util.List} of {@link java.sql.Time} objects and a database
  * <em>varchar</em> field.
  *
- * @author Guillaume Nodet
  * @version $Id$
  */
-public class TimeList2VarcharFieldConversion implements FieldConversion
+public class TimeList2VarcharFieldConversion extends AbstractList2VarcharConversion
 {
-
-    private static final String NULLVALUE = "#NULL#";
-    private static final String EMPTYCOLLEC = "#EMTPY#";
-
     public TimeList2VarcharFieldConversion()
     {
     }
 
-    /* (non-Javadoc)
-     * @see org.apache.ojb.broker.accesslayer.conversions.FieldConversion#javaToSql(java.lang.Object)
-     */
-    public Object javaToSql(Object source) throws ConversionException
+    protected void addEntryToList(List resultList, String strEntry)
     {
-        if (source == null)
-        {
-            return NULLVALUE;
-        }
-
-        try
+        boolean old = strEntry.indexOf(":") > 0;
+        String value = checkResult(strEntry);
+        // backward compatible for string of form 01:00:00
+        if(old)
         {
-            List timeList = (List) source;
-            if (timeList.isEmpty())
-            {
-                return NULLVALUE;
-            }
-
-            StringBuffer result = new StringBuffer();
-            for (int i = 0; i < timeList.size(); i++)
-            {
-                Time obj = (Time) timeList.get(i);
-                String newSt = obj.toString();
-                // introduced in JDK 1.4, replace with commons-lang
-                // newSt = newSt.replaceAll("#", "##");
-                newSt = StringUtils.replace(newSt, "#", "##");
-                result.append(newSt);
-                result.append("#");
-            }
-            return result.toString();
+            resultList.add(value != null ? Time.valueOf(value) : null);
         }
-        catch (ClassCastException e)
+        // the new version with millisecond precision
+        else
         {
-            throw new ConversionException("Object is not a List of Time it is a" + source.getClass().getName());
+            resultList.add(value != null ? new Time(Long.parseLong(value)) : null);
         }
     }
 
-    /* (non-Javadoc)
-     * @see org.apache.ojb.broker.accesslayer.conversions.FieldConversion#sqlToJava(java.lang.Object)
-     */
-    public Object sqlToJava(Object source) throws ConversionException
+    protected String convertListEntryToString(Object entry)
     {
-        if (source == null)
+        if(entry != null)
         {
-            return null;
+            // use #getTime instead of #toString to avoid data corruption
+            return Long.toString(((Time) entry).getTime());
         }
-        if (source.toString().equals(NULLVALUE))
+        else
         {
             return null;
         }
-        if (source.toString().equals(EMPTYCOLLEC))
-        {
-            return new ArrayList();
-        }
-
-        List v = new ArrayList();
-        String input = source.toString();
-        int pos = input.indexOf("#");
-
-        while (pos >= 0)
-        {
-            if (pos == 0)
-            {
-                v.add("");
-            }
-            else
-            {
-                v.add(Time.valueOf(input.substring(0, pos)));
-            }
-
-            if (pos + 1 > input.length())
-            {
-                //# at end causes outof bounds
-                break;
-            }
-
-            input = input.substring(pos + 1, input.length());
-            pos = input.indexOf("#");
-        }
-        return v;
     }
 }

Modified: db/ojb/trunk/src/java/org/apache/ojb/broker/accesslayer/sql/SqlExistStatement.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/java/org/apache/ojb/broker/accesslayer/sql/SqlExistStatement.java?rev=422228&r1=422227&r2=422228&view=diff
==============================================================================
--- db/ojb/trunk/src/java/org/apache/ojb/broker/accesslayer/sql/SqlExistStatement.java (original)
+++ db/ojb/trunk/src/java/org/apache/ojb/broker/accesslayer/sql/SqlExistStatement.java Sat
Jul 15 07:17:29 2006
@@ -25,7 +25,6 @@
  * Generate a select to check existence of an object.
  * Something like "SELECT id_1 FROM myTable where id_1 = 123 and id_2 = 'kjngzt'".
  *
- * @author <a href="mailto:arminw@apache.org">Armin Waibel</a>
  * @version $Id$
  */
 public class SqlExistStatement extends SqlPkStatement

Modified: db/ojb/trunk/src/java/org/apache/ojb/broker/accesslayer/sql/SqlGeneratorDefaultImpl.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/java/org/apache/ojb/broker/accesslayer/sql/SqlGeneratorDefaultImpl.java?rev=422228&r1=422227&r2=422228&view=diff
==============================================================================
--- db/ojb/trunk/src/java/org/apache/ojb/broker/accesslayer/sql/SqlGeneratorDefaultImpl.java
(original)
+++ db/ojb/trunk/src/java/org/apache/ojb/broker/accesslayer/sql/SqlGeneratorDefaultImpl.java
Sat Jul 15 07:17:29 2006
@@ -40,15 +40,12 @@
  * This Class is responsible for building sql statements
  * Objects fields and their repective values are accessed by Java reflection
  *
- * @author <a href="mailto:thma@apache.org">Thomas Mahler<a>
- * @author <a href="mailto:rgallagh@bellsouth.net">Ron Gallagher</a>
- * @author <a href="mailto:rburt3@mchsi.com">Randall Burt</a>
  * @version $Id$
  */
 public class SqlGeneratorDefaultImpl implements SqlGenerator
 {
-    private Logger m_logger = LoggerFactory.getLogger(SqlGeneratorDefaultImpl.class);
-    private Platform m_platform;
+    private Logger logger = LoggerFactory.getLogger(SqlGeneratorDefaultImpl.class);
+    private Platform platform;
     /*
     arminw:
     TODO: In ClassDescriptor we need support for "field change event" listener if we allow
@@ -65,7 +62,7 @@
 
     public SqlGeneratorDefaultImpl(Platform platform)
     {
-        m_platform = platform;
+        this.platform = platform;
     }
 
     /** @see SqlGenerator#getGenericPreparedStatement(int, String, String[], String[]) */
@@ -92,41 +89,41 @@
 
     private SqlStatement buildGenericDelete(String table, String[] whereClauseColumns)
     {
-        SqlStatement result = (new SqlGenericDeleteStatement(m_platform, m_logger, table,
whereClauseColumns));
+        SqlStatement result = (new SqlGenericDeleteStatement(platform, logger, table, whereClauseColumns));
 
-        if(m_logger.isDebugEnabled())
+        if(logger.isDebugEnabled())
         {
-            m_logger.debug("SQL:" + result.getStatement());
+            logger.debug("SQL:" + result.getStatement());
         }
         return result;
     }
 
     private SqlStatement buildGenericInsert(String table, String[] affectedColumns)
     {
-        SqlStatement sql = new SqlGenericInsertStatement(m_platform, m_logger, table, affectedColumns);
-        if(m_logger.isDebugEnabled())
+        SqlStatement sql = new SqlGenericInsertStatement(platform, logger, table, affectedColumns);
+        if(logger.isDebugEnabled())
         {
-            m_logger.debug("SQL:" + sql.getStatement());
+            logger.debug("SQL:" + sql.getStatement());
         }
         return sql;
     }
 
     private SqlStatement buildGenericSelect(String table, String[] affectedColumns, String[]
whereClauseColumns)
     {
-        SqlStatement sql = new SqlGenericSelectStatement(m_platform, m_logger, table, affectedColumns,
whereClauseColumns);
-        if(m_logger.isDebugEnabled())
+        SqlStatement sql = new SqlGenericSelectStatement(platform, logger, table, affectedColumns,
whereClauseColumns);
+        if(logger.isDebugEnabled())
         {
-            m_logger.debug("SQL: " + sql.getStatement());
+            logger.debug("SQL: " + sql.getStatement());
         }
         return sql;
     }
 
     private SqlStatement buildGenericUpdate(String table, String[] affectedColumns, String[]
whereClauseColumns)
     {
-        SqlStatement result = (new SqlGenericUpdateStatement(m_platform, m_logger, table,
affectedColumns, whereClauseColumns));
-        if(m_logger.isDebugEnabled())
+        SqlStatement result = (new SqlGenericUpdateStatement(platform, logger, table, affectedColumns,
whereClauseColumns));
+        if(logger.isDebugEnabled())
         {
-            m_logger.debug("SQL:" + result.getStatement());
+            logger.debug("SQL:" + result.getStatement());
         }
         return result;
     }
@@ -143,23 +140,22 @@
         SqlStatement sql = sfc.getDeleteSql();
         if(sql == null)
         {
-
             ProcedureDescriptor pd = cld.getDeleteProcedure();
 
             if(pd == null)
             {
-                sql = new SqlDeleteByPkStatement(m_platform, m_logger, cld);
+                sql = new SqlDeleteByPkStatement(platform, logger, cld);
             }
             else
             {
-                sql = new SqlProcedureStatement(pd, m_logger);
+                sql = new SqlProcedureStatement(pd, logger);
             }
             // set the sql string
             sfc.setDeleteSql(sql);
 
-            if(m_logger.isDebugEnabled())
+            if(logger.isDebugEnabled())
             {
-                m_logger.debug("SQL:" + sql.getStatement());
+                logger.debug("SQL:" + sql.getStatement());
             }
         }
         return sql;
@@ -182,18 +178,18 @@
 
             if(pd == null)
             {
-                sql = new SqlInsertStatement(m_platform, m_logger, cld);
+                sql = new SqlInsertStatement(platform, logger, cld);
             }
             else
             {
-                sql = new SqlProcedureStatement(pd, m_logger);
+                sql = new SqlProcedureStatement(pd, logger);
             }
             // set the sql string
             sfc.setInsertSql(sql);
 
-            if(m_logger.isDebugEnabled())
+            if(logger.isDebugEnabled())
             {
-                m_logger.debug("SQL:" + sql.getStatement());
+                logger.debug("SQL:" + sql.getStatement());
             }
         }
         return sql;
@@ -214,19 +210,19 @@
             ProcedureDescriptor pd = cld.getSelectByPKProcedure();
             if(pd == null)
             {
-                sql = new SqlSelectByPkStatement(m_platform, m_logger, cld);
+                sql = new SqlSelectByPkStatement(platform, logger, cld);
             }
             else
             {
-                sql = new SqlProcedureStatement(pd, m_logger);
+                sql = new SqlProcedureStatement(pd, logger);
             }
 
             // set the sql string
             sfc.setSelectByPKSql(sql);
 
-            if(m_logger.isDebugEnabled())
+            if(logger.isDebugEnabled())
             {
-                m_logger.debug("SQL:" + sql.getStatement());
+                logger.debug("SQL:" + sql.getStatement());
             }
         }
         return sql;
@@ -240,12 +236,12 @@
         if(sql == null)
         {
             // TODO: Should we support a procedure call for this too??
-            sql = new SqlExistStatement(m_platform, m_logger, cld);
+            sql = new SqlExistStatement(platform, logger, cld);
             // set the sql string
             sfc.setSelectExists(sql);
-            if(m_logger.isDebugEnabled())
+            if(logger.isDebugEnabled())
             {
-                m_logger.debug("SQL:" + sql.getStatement());
+                logger.debug("SQL:" + sql.getStatement());
             }
         }
         return sql;
@@ -265,17 +261,17 @@
         if((query instanceof QueryByExample) && (pd != null))
         {
             // Special case for QueryByExample and SelectByFKProcedure
-            sql = new SqlProcedureFKStatement(pd, (QueryByExample) query, m_logger);
+            sql = new SqlProcedureFKStatement(pd, (QueryByExample) query, logger);
         }
         else
         {
             // All other queries
-            sql = new SqlSelectStatement(m_platform, m_logger, cld, query);
+            sql = new SqlSelectStatement(platform, logger, cld, query);
         }
 
-        if (m_logger.isDebugEnabled())
+        if (logger.isDebugEnabled())
         {
-            m_logger.debug("SQL:" + sql.getStatement());
+            logger.debug("SQL:" + sql.getStatement());
         }
 
         return sql;
@@ -289,7 +285,7 @@
      */
     public SelectStatement getPreparedSelectPkStatement(Query query, ClassDescriptor cld)
     {
-        return new SqlSelectPkStatement(m_platform, m_logger, cld, query);
+        return new SqlSelectPkStatement(platform, logger, cld, query);
     }
 
     /**
@@ -300,7 +296,7 @@
      */
     public SqlStatement getPreparedDeleteStatement(Query query, ClassDescriptor cld)
     {
-        return new SqlDeleteByQuery(m_platform, m_logger, cld, query);
+        return new SqlDeleteByQuery(platform, logger, cld, query);
     }
 
     /**
@@ -319,18 +315,18 @@
 
             if(pd == null)
             {
-                result = new SqlUpdateStatement(m_platform, m_logger, cld);
+                result = new SqlUpdateStatement(platform, logger, cld);
             }
             else
             {
-                result = new SqlProcedureStatement(pd, m_logger);
+                result = new SqlProcedureStatement(pd, logger);
             }
             // set the sql string
             sfc.setUpdateSql(result);
 
-            if(m_logger.isDebugEnabled())
+            if(logger.isDebugEnabled())
             {
-                m_logger.debug("SQL:" + result.getStatement());
+                logger.debug("SQL:" + result.getStatement());
             }
         }
         return result;
@@ -382,11 +378,11 @@
             }
             if(result == null)
             {
-                result = new SqlUpdateFieldsStatement(m_platform, m_logger, cld, fields);
+                result = new SqlUpdateFieldsStatement(platform, logger, cld, fields);
                 sfc.setLastUsedUpdateFieldsSql((SqlUpdateFieldsStatement) result);
             }
         }
-        if(m_logger.isDebugEnabled()) m_logger.debug("SQL:" + result.getStatement());
+        if(logger.isDebugEnabled()) logger.debug("SQL:" + result.getStatement());
         return result;
     }
 
@@ -580,7 +576,7 @@
     /** @return Returns the platform. */
     public Platform getPlatform()
     {
-        return m_platform;
+        return platform;
     }
 
     /**
@@ -690,4 +686,5 @@
             this.selectExists = selectExists;
         }
     }
+
 }

Modified: db/ojb/trunk/src/java/org/apache/ojb/broker/accesslayer/sql/SqlInsertStatement.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/java/org/apache/ojb/broker/accesslayer/sql/SqlInsertStatement.java?rev=422228&r1=422227&r2=422228&view=diff
==============================================================================
--- db/ojb/trunk/src/java/org/apache/ojb/broker/accesslayer/sql/SqlInsertStatement.java (original)
+++ db/ojb/trunk/src/java/org/apache/ojb/broker/accesslayer/sql/SqlInsertStatement.java Sat
Jul 15 07:17:29 2006
@@ -26,7 +26,6 @@
 /**
  * Model an INSERT Statement
  *
- * @author <a href="mailto:jbraeuchi@gmx.ch">Jakob Braeuchi</a>
  * @version $Id$
  */
 public class SqlInsertStatement extends SqlPkStatement
@@ -103,5 +102,6 @@
         }
         stmt.append(") ");
     }
+
 }
 

Modified: db/ojb/trunk/src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java?rev=422228&r1=422227&r2=422228&view=diff
==============================================================================
--- db/ojb/trunk/src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java (original)
+++ db/ojb/trunk/src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java Sat
Jul 15 07:17:29 2006
@@ -261,7 +261,6 @@
      * @param anAttrInfo the name of the attribute
      * @param translate
      * @param buf the Buffer
-     * @return The column name.
      */
     protected void appendColumn(SingleAttributeInfo anAttrInfo, boolean translate, StringBuffer
buf)
     {

Modified: db/ojb/trunk/src/java/org/apache/ojb/broker/accesslayer/sql/SqlSelectByPkStatement.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/java/org/apache/ojb/broker/accesslayer/sql/SqlSelectByPkStatement.java?rev=422228&r1=422227&r2=422228&view=diff
==============================================================================
--- db/ojb/trunk/src/java/org/apache/ojb/broker/accesslayer/sql/SqlSelectByPkStatement.java
(original)
+++ db/ojb/trunk/src/java/org/apache/ojb/broker/accesslayer/sql/SqlSelectByPkStatement.java
Sat Jul 15 07:17:29 2006
@@ -26,13 +26,13 @@
 /**
  * Model a SELECT Statement by Primary Key
  * 
- * @author <a href="mailto:jbraeuchi@gmx.ch">Jakob Braeuchi</a>
  * @version $Id$
  */
 public class SqlSelectByPkStatement extends SqlSelectStatement
 {
     /**
      * Constructor for SqlSelectByPkStatement.
+     *
      * @param cld
      * @param logger
      */

Modified: db/ojb/trunk/src/java/org/apache/ojb/broker/accesslayer/sql/SqlSelectStatement.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/java/org/apache/ojb/broker/accesslayer/sql/SqlSelectStatement.java?rev=422228&r1=422227&r2=422228&view=diff
==============================================================================
--- db/ojb/trunk/src/java/org/apache/ojb/broker/accesslayer/sql/SqlSelectStatement.java (original)
+++ db/ojb/trunk/src/java/org/apache/ojb/broker/accesslayer/sql/SqlSelectStatement.java Sat
Jul 15 07:17:29 2006
@@ -39,7 +39,6 @@
 /**
  * Model a SELECT Statement
  *
- * @author <a href="mailto:jbraeuchi@gmx.ch">Jakob Braeuchi</a>
  * @version $Id$
  */
 public class SqlSelectStatement extends SqlQueryStatement implements SelectStatement
@@ -166,13 +165,13 @@
         }
         buf.append(" ELSE '").append(cld.getClassNameOfObject()).append("'");
         buf.append(" END AS " + SqlHelper.OJB_CLASS_COLUMN);
-
         // signal the use of the ojbClassColumn
         setUseOjbClassColumn(true);
     }
 
     /**
      * Return the Fields to be selected.
+     *
      * @return the Fields to be selected
      */
     protected FieldDescriptor[] getFieldsForSelect()
@@ -186,6 +185,7 @@
 
     /**
      * Return the Fields to be selected.
+     *
      * @param cld the ClassDescriptor
      * @return the Fields to be selected
      */
@@ -230,6 +230,7 @@
     
     /**
      * Appends to the statement a comma separated list of column names.
+     *
      * @param columns defines the columns to be selected (for reports)
      * @return list of column names
      */
@@ -458,6 +459,16 @@
      */
     public boolean isUseOjbClassColumn()
     {
+        // BRJ: force generation of sql-string.
+        //
+        // this is a workaraoundd for the problem described
+        // in InheritanceMultipleTableTest#testLookupByIdentity_2
+        // the problem is caused by JdbcAccessImpl#materializeObject not caching
+        // the SqlSelectStatement and passing an 'empty' SqlSelectStatement to ResultSetAndStatement
+        //
+        // TODO: remove this workaround for ojb 1.x
+        getStatement();
+
         return useOjbClassColumn;
     }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


Mime
View raw message