db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arm...@apache.org
Subject svn commit: r414928 - in /db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/lob: LobHandle.java LobHelper.java LobHelperImpl.java
Date Fri, 16 Jun 2006 21:34:25 GMT
Author: arminw
Date: Fri Jun 16 14:34:25 2006
New Revision: 414928

URL: http://svn.apache.org/viewvc?rev=414928&view=rev
Log:
improve lob handling (using better support for advanced jdbc data types)

Modified:
    db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/lob/LobHandle.java
    db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/lob/LobHelper.java
    db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/lob/LobHelperImpl.java

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/lob/LobHandle.java
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/lob/LobHandle.java?rev=414928&r1=414927&r2=414928&view=diff
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/lob/LobHandle.java (original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/lob/LobHandle.java Fri
Jun 16 14:34:25 2006
@@ -161,9 +161,14 @@
 
     public void checkActive()
     {
-        if(!isTransient() && !isCoupled()) throw new InactiveLobException(
+        if(!(isTransient() || isCoupled())) throw new InactiveLobException(
                 "Current LOB is not valid for access (no active PB-tx or PB-tx changed),
"
                         + "refresh the persistent object LOB content after PB-tx starts");
+    }
+
+    public boolean isActive()
+    {
+        return isTransient() || isCoupled();
     }
 
 

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/lob/LobHelper.java
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/lob/LobHelper.java?rev=414928&r1=414927&r2=414928&view=diff
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/lob/LobHelper.java (original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/lob/LobHelper.java Fri
Jun 16 14:34:25 2006
@@ -21,6 +21,7 @@
 import java.sql.Clob;
 
 import org.apache.ojb.broker.metadata.ClassDescriptor;
+import org.apache.ojb.broker.metadata.FieldDescriptor;
 
 /**
  * Helper class support handling of LOB-locator-object
@@ -107,14 +108,13 @@
 
     /**
      * Refresh all LOB-locator instances of the specified persistence capable object
-     * if the following conditions are true for the target object:
+     * if the following conditions are <em>true</em> for the target object:
      * <ul>
      * <li>active {@link org.apache.ojb.broker.PersistenceBroker}-tx is running</li>
      * <li>contains LOB fields</li>
      * <li>LOB fields wrapped by OJB's LOB wrapping classes (normally
      * all LOB fields of persistence capable objects are automatically wrapped
-     * with OJB specific wrapper classes by internal calls to
-     * {@link #wrapLobFields(org.apache.ojb.broker.metadata.ClassDescriptor, Object)})</li>
+     * internal with OJB specific wrapper classes</li>
      * <li>one or more fields are inactive/invalid (there is no active
      * {@link org.apache.ojb.broker.PersistenceBroker} instance associated with detected
LOB-fields)</li>
      * </ul>
@@ -126,6 +126,18 @@
      */
     public void refreshLob(Object target, ClassDescriptor cld);
 
+    /**
+     * Internal used method!
+     * <br/>
+     * Wrap the specified LOB value ({@link java.sql.Blob} and {@link java.sql.Clob}
+     * instances returned by the database) with OJB specific LOB-wrapper class.
+     *
+     * @param fld The field of the specified value.
+     * @param value The LOB content value of the field.
+     * @return The wrapped LOB content.
+     */
+    public Object wrapLobField(FieldDescriptor fld, Object value);
+
 //    /**
 //     * Internal used method!
 //     * <br/>
@@ -140,16 +152,16 @@
 //     */
 //    public void refreshLob(FieldDescriptor lobField, Object target, FieldDescriptor[] pkFields);
 
-    /**
-     * Internal used method!
-     * <br/>
-     * Wraps the target object LOB instances ({@link java.sql.Blob} and {@link java.sql.Clob}
-     * instances returned by the database) with OJB specific LOB-wrapper classes.
-     *
-     * @param cld The {@link org.apache.ojb.broker.metadata.ClassDescriptor} of the target
object.
-     * @param target The target object.
-     */
-    public void wrapLobFields(ClassDescriptor cld, Object target);
+//    /**
+//     * Internal used method!
+//     * <br/>
+//     * Wraps the target object LOB instances ({@link java.sql.Blob} and {@link java.sql.Clob}
+//     * instances returned by the database) with OJB specific LOB-wrapper classes.
+//     *
+//     * @param cld The {@link org.apache.ojb.broker.metadata.ClassDescriptor} of the target
object.
+//     * @param target The target object.
+//     */
+//    public void wrapLobFields(ClassDescriptor cld, Object target);
 
 //    /**
 //     * Returns <em>true</em> if the specified persistence capable object

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/lob/LobHelperImpl.java
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/lob/LobHelperImpl.java?rev=414928&r1=414927&r2=414928&view=diff
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/lob/LobHelperImpl.java
(original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/lob/LobHelperImpl.java
Fri Jun 16 14:34:25 2006
@@ -213,30 +213,46 @@
         return FieldTypes.BlobFieldType.class.isAssignableFrom(fld.getJdbcType().getFieldType().getClass());
     }
 
-    public void wrapLobFields(ClassDescriptor cld, Object target)
+//    public void wrapLobFields(ClassDescriptor cld, Object target)
+//    {
+//        if(cld.hasLobField())
+//        {
+//            FieldDescriptor[] fields = cld.getFieldDescriptor(true);
+//            for(int i = 0; i < fields.length; i++)
+//            {
+//                FieldDescriptor field = fields[i];
+//                if(field.isLobFieldType())
+//                {
+//                    Object lob = field.getPersistentField().get(target);
+//                    if(lob != null && !(lob instanceof LobHandle))
+//                    {
+//                        if(isBlobField(field))
+//                        {
+//                            field.getPersistentField().set(target, new BlobHandle(broker,
(Blob) lob));
+//                        }
+//                        else
+//                        {
+//                            field.getPersistentField().set(target, new ClobHandle(broker,
(Clob) lob));
+//                        }
+//                    }
+//                }
+//            }
+//        }
+//    }
+
+    public Object wrapLobField(FieldDescriptor fld, Object value)
     {
-        if(cld.hasLobField())
+        if(value != null && !(value instanceof LobHandle))
         {
-            FieldDescriptor[] fields = cld.getFieldDescriptor(true);
-            for(int i = 0; i < fields.length; i++)
+            if(isBlobField(fld))
             {
-                FieldDescriptor field = fields[i];
-                if(field.isLobFieldType())
-                {
-                    Object lob = field.getPersistentField().get(target);
-                    if(lob != null && !(lob instanceof LobHandle))
-                    {
-                        if(isBlobField(field))
-                        {
-                            field.getPersistentField().set(target, new BlobHandle(broker,
(Blob) lob));
-                        }
-                        else
-                        {
-                            field.getPersistentField().set(target, new ClobHandle(broker,
(Clob) lob));
-                        }
-                    }
-                }
+                return new BlobHandle(broker, (Blob) value);
+            }
+            else
+            {
+                return new ClobHandle(broker, (Clob) value);
             }
         }
+        return value;
     }
 }



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