svn commit: r431161 - in /incubator/ofbiz/trunk/framework/entity: config/entityengine.xml dtd/entity-config.xsd fieldtype/fieldtypepostgres.xml src/org/ofbiz/entity/config/DatasourceInfo.java src/org/ofbiz/entity/jdbc/SQLProcessor.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r431161 - in /incubator/ofbiz/trunk/framework/entity: config/entityengine.xml dtd/entity-config.xsd fieldtype/fieldtypepostgres.xml src/org/ofbiz/entity/config/DatasourceInfo.java src/org/ofbiz/entity/jdbc/SQLProcessor.java

jonesde
Author: jonesde
Date: Sun Aug 13 04:19:12 2006
New Revision: 431161

URL: http://svn.apache.org/viewvc?rev=431161&view=rev
Log:
Added option to use binary type for blobs, configurable on the datasource element in entityengine.xml; this is mainly for Postgres and is necessary to use the BYTEA type for blob; I have tested this and it appears to be working fine; this should fix Undersun Jira #OFBIZ-334

Modified:
    incubator/ofbiz/trunk/framework/entity/config/entityengine.xml
    incubator/ofbiz/trunk/framework/entity/dtd/entity-config.xsd
    incubator/ofbiz/trunk/framework/entity/fieldtype/fieldtypepostgres.xml
    incubator/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/DatasourceInfo.java
    incubator/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/jdbc/SQLProcessor.java

Modified: incubator/ofbiz/trunk/framework/entity/config/entityengine.xml
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/framework/entity/config/entityengine.xml?rev=431161&r1=431160&r2=431161&view=diff
==============================================================================
--- incubator/ofbiz/trunk/framework/entity/config/entityengine.xml (original)
+++ incubator/ofbiz/trunk/framework/entity/config/entityengine.xml Sun Aug 13 04:19:12 2006
@@ -44,7 +44,7 @@
     -->
 
     <delegator name="default" entity-model-reader="main" entity-group-reader="main" entity-eca-reader="main" distributed-cache-clear-enabled="false">
-        <group-map group-name="org.ofbiz" datasource-name="localderby"/>
+        <group-map group-name="org.ofbiz" datasource-name="localpostgres"/>
         <group-map group-name="org.ofbiz.odbc" datasource-name="localderbyodbc"/>
     </delegator>
     <delegator name="default-no-eca" entity-model-reader="main" entity-group-reader="main" entity-eca-reader="main" entity-eca-enabled="false" distributed-cache-clear-enabled="false">
@@ -291,7 +291,8 @@
             check-on-start="true"
             add-missing-on-start="true"
             use-fk-initially-deferred="false"
-            join-style="ansi">
+            join-style="ansi"
+            use-binary-type-for-blob="true">
             <!-- use this attribute to make the EntityListIterator more effective for pgjdbc 7.5devel and later:
                 result-fetch-size="50"
             -->

Modified: incubator/ofbiz/trunk/framework/entity/dtd/entity-config.xsd
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/framework/entity/dtd/entity-config.xsd?rev=431161&r1=431160&r2=431161&view=diff
==============================================================================
--- incubator/ofbiz/trunk/framework/entity/dtd/entity-config.xsd (original)
+++ incubator/ofbiz/trunk/framework/entity/dtd/entity-config.xsd Sun Aug 13 04:19:12 2006
@@ -359,6 +359,14 @@
                 </xs:restriction>
             </xs:simpleType>
         </xs:attribute>
+        <xs:attribute name="use-binary-type-for-blob" default="false">
+            <xs:simpleType>
+                <xs:restriction base="xs:token">
+                    <xs:enumeration value="true"/>
+                    <xs:enumeration value="false"/>
+                </xs:restriction>
+            </xs:simpleType>
+        </xs:attribute>
         <xs:attribute type="xs:string" name="table-type"/>
         <xs:attribute type="xs:string" name="character-set"/>
         <xs:attribute type="xs:string" name="collate"/>

Modified: incubator/ofbiz/trunk/framework/entity/fieldtype/fieldtypepostgres.xml
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/framework/entity/fieldtype/fieldtypepostgres.xml?rev=431161&r1=431160&r2=431161&view=diff
==============================================================================
--- incubator/ofbiz/trunk/framework/entity/fieldtype/fieldtypepostgres.xml (original)
+++ incubator/ofbiz/trunk/framework/entity/fieldtype/fieldtypepostgres.xml Sun Aug 13 04:19:12 2006
@@ -20,7 +20,7 @@
         xsi:noNamespaceSchemaLocation="http://www.ofbiz.org/dtds/fieldtypemodel.xsd">
   <!-- ===================== field-type-def ==================== -->
    <!-- General Types -->
-    <field-type-def type="blob" sql-type="OID" java-type="java.lang.Object"></field-type-def>
+    <field-type-def type="blob" sql-type="BYTEA" java-type="java.lang.Object"></field-type-def>
 
     <field-type-def type="date-time" sql-type="TIMESTAMPTZ" java-type="java.sql.Timestamp"></field-type-def>
     <field-type-def type="date" sql-type="DATE" java-type="java.sql.Date"></field-type-def>

Modified: incubator/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/DatasourceInfo.java
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/DatasourceInfo.java?rev=431161&r1=431160&r2=431161&view=diff
==============================================================================
--- incubator/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/DatasourceInfo.java (original)
+++ incubator/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/DatasourceInfo.java Sun Aug 13 04:19:12 2006
@@ -80,6 +80,7 @@
     public boolean aliasViews = true;
     public boolean alwaysUseConstraintKeyword = false;
     public boolean dropFkUseForeignKeyKeyword = false;
+    public boolean useBinaryTypeForBlob = false;
     public String tableType = null;
     public String characterSet = null;
     public String collate = null;
@@ -112,6 +113,7 @@
             Debug.logWarning("datasource def not found with name " + this.name + ", using default for join-style (ansi)", module);
             Debug.logWarning("datasource def not found with name " + this.name + ", using default for always-use-constraint-keyword (false)", module);
             Debug.logWarning("datasource def not found with name " + this.name + ", using default for drop-fk-use-foreign-key-keyword (false)", module);
+            Debug.logWarning("datasource def not found with name " + this.name + ", using default for use-binary-type-for-blob (false)", module);
             Debug.logWarning("datasource def not found with name " + this.name + ", using default for table-type (none)", module);
             Debug.logWarning("datasource def not found with name " + this.name + ", using default for character-set (none)", module);
             Debug.logWarning("datasource def not found with name " + this.name + ", using default for collate (none)", module);
@@ -159,6 +161,7 @@
             // anything but true is false
             this.alwaysUseConstraintKeyword = "true".equals(datasourceElement.getAttribute("always-use-constraint-keyword"));
             this.dropFkUseForeignKeyKeyword = "true".equals(datasourceElement.getAttribute("drop-fk-use-foreign-key-keyword"));
+            this.useBinaryTypeForBlob = "true".equals(datasourceElement.getAttribute("use-binary-type-for-blob"));
             
             this.tableType = datasourceElement.getAttribute("table-type");
             this.characterSet = datasourceElement.getAttribute("character-set");

Modified: incubator/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/jdbc/SQLProcessor.java
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/jdbc/SQLProcessor.java?rev=431161&r1=431160&r2=431161&view=diff
==============================================================================
--- incubator/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/jdbc/SQLProcessor.java (original)
+++ incubator/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/jdbc/SQLProcessor.java Sun Aug 13 04:19:12 2006
@@ -792,7 +792,12 @@
                 throw new SQLException(ex.getMessage());
             }
         } else {
-            _ps.setNull(_ind, Types.BLOB);
+            DatasourceInfo datasourceInfo = EntityConfigUtil.getDatasourceInfo(this.helperName);
+            if (datasourceInfo.useBinaryTypeForBlob) {
+                _ps.setNull(_ind, Types.BINARY);
+            } else {
+                _ps.setNull(_ind, Types.BLOB);
+            }
         }
 
         _ind++;