db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arm...@apache.org
Subject svn commit: r414933 - /db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/FieldDescriptor.java
Date Fri, 16 Jun 2006 21:38:08 GMT
Author: arminw
Date: Fri Jun 16 14:38:08 2006
New Revision: 414933

URL: http://svn.apache.org/viewvc?rev=414933&view=rev
Log:
add new methods to improve support for advanced jdbc data types (like JAVA_OBJECT) and ease
read in of result set columns

Modified:
    db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/FieldDescriptor.java

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/FieldDescriptor.java
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/FieldDescriptor.java?rev=414933&r1=414932&r2=414933&view=diff
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/FieldDescriptor.java
(original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/FieldDescriptor.java
Fri Jun 16 14:38:08 2006
@@ -16,6 +16,8 @@
  */
 
 import java.io.Serializable;
+import java.sql.CallableStatement;
+import java.sql.SQLException;
 import java.sql.Types;
 import java.util.Comparator;
 
@@ -24,10 +26,12 @@
 import org.apache.commons.lang.builder.ToStringBuilder;
 import org.apache.commons.lang.builder.ToStringStyle;
 import org.apache.ojb.broker.OJBRuntimeException;
-import org.apache.ojb.broker.accesslayer.conversions.FieldConversion;
-import org.apache.ojb.broker.metadata.fieldaccess.AnonymousPersistentField;
+import org.apache.ojb.broker.PersistenceBroker;
 import org.apache.ojb.broker.accesslayer.NullCheck;
 import org.apache.ojb.broker.accesslayer.NullCheckDefaultImpl;
+import org.apache.ojb.broker.accesslayer.ResultSetAndStatement;
+import org.apache.ojb.broker.accesslayer.conversions.FieldConversion;
+import org.apache.ojb.broker.metadata.fieldaccess.AnonymousPersistentField;
 import org.apache.ojb.broker.util.ClassHelper;
 
 /**
@@ -542,6 +546,73 @@
     public boolean isLobFieldType()
     {
         return getJdbcType().getFieldType().isLobField();
+    }
+
+
+    /**
+     * Reads in the value of the field/column represented by this <code>FieldDescriptor</code>.
+     *
+     * @param rs_stmt The current used {@link org.apache.ojb.broker.accesslayer.ResultSetAndStatement}
instance.
+     * @param convert If set <em>true</em> a
+     * {@link org.apache.ojb.broker.accesslayer.conversions.FieldConversion#sqlToJava(Object)}
conversion call
+     * is done.
+     * @return The read in value of this field.
+     * @throws SQLException
+     */
+    public Object readValue(final ResultSetAndStatement rs_stmt, boolean convert)
+            throws SQLException
+    {
+        int idx = rs_stmt.m_sql.getColumnIndex(this);
+        return readValue(rs_stmt, idx, convert);
+    }
+
+    /**
+     * Reads in the value of the field/column represented by this <code>FieldDescriptor</code>.
+     *
+     * @param rs_stmt The current used {@link org.apache.ojb.broker.accesslayer.ResultSetAndStatement}
instance.
+     * @param index The result set column index.
+     * @param convert If set <em>true</em> a
+     * {@link org.apache.ojb.broker.accesslayer.conversions.FieldConversion#sqlToJava(Object)}
conversion call
+     * is done.
+     * @return The read in value of this field.
+     * @throws SQLException
+     */
+    public Object readValue(final ResultSetAndStatement rs_stmt, int index, boolean convert)
+            throws SQLException
+    {
+        Object val = getJdbcType().getObjectFromColumn(rs_stmt.m_rs, null, getColumnName(),
index);
+        val = rs_stmt.m_platform.postPrepareReadInValue(this, val);
+        if(convert) val = getFieldConversion().sqlToJava(val);
+        if(isLobFieldType())
+        {
+            val = rs_stmt.m_broker.serviceLobHelper().wrapLobField(this, val);
+        }
+        return val;
+    }
+
+    /**
+     * Reads in the value of the field/column represented by this <code>FieldDescriptor</code>.
+     *
+     * @param broker The current used <code>PersistenceBroker</code>.
+     * @param stmt The current used <code>CallableStatement</code>.
+     * @param index The result set column index.
+     * @param convert If set <em>true</em> a
+     * {@link org.apache.ojb.broker.accesslayer.conversions.FieldConversion#sqlToJava(Object)}
conversion call
+     * is done.
+     * @return The read in value of this field.
+     * @throws SQLException
+     */
+    public Object readValue(final PersistenceBroker broker, final CallableStatement stmt,
int index, boolean convert)
+            throws SQLException
+    {
+        Object val = getJdbcType().getObjectFromColumn(stmt, index);
+        val = broker.serviceConnectionManager().getSupportedPlatform().postPrepareReadInValue(this,
val);
+        if(convert) val = getFieldConversion().sqlToJava(val);
+        if(isLobFieldType())
+        {
+            val = broker.serviceLobHelper().wrapLobField(this, val);
+        }
+        return val;
     }
 
     /*



---------------------------------------------------------------------
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