You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by nt...@apache.org on 2022/01/31 14:54:50 UTC

[cayenne] branch master updated (d6beb87 -> b451078)

This is an automated email from the ASF dual-hosted git repository.

ntimofeev pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/cayenne.git.


    from d6beb87  CAY-2729 minor code cleanup
     new 47b5fab  fix H2 clob streaming
     new b451078  CAY-2731 Exception when setting a CLOB on H2 v2.0.202

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 RELEASE-NOTES.txt                                  |  1 +
 .../java/org/apache/cayenne/dba/h2/H2Adapter.java  | 14 ++++++++
 .../java/org/apache/cayenne/dba/h2/H2CharType.java | 38 ++++++++++++++++++++++
 3 files changed, 53 insertions(+)
 create mode 100644 cayenne-server/src/main/java/org/apache/cayenne/dba/h2/H2CharType.java

[cayenne] 02/02: CAY-2731 Exception when setting a CLOB on H2 v2.0.202

Posted by nt...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ntimofeev pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cayenne.git

commit b451078f7923db06b8818fdc4574d74af2ffcc5f
Author: Nikita Timofeev <st...@gmail.com>
AuthorDate: Mon Jan 31 17:54:38 2022 +0300

    CAY-2731 Exception when setting a CLOB on H2 v2.0.202
---
 RELEASE-NOTES.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt
index 67ca5ae..bd6d25c 100644
--- a/RELEASE-NOTES.txt
+++ b/RELEASE-NOTES.txt
@@ -22,6 +22,7 @@ CAY-2724 Duplicating relationship after editing its name
 CAY-2727 Modeler: cgen destDir Unix platform path separator
 CAY-2729 Unable to use custom templates from a folder at upper level then datamap
 CAY-2730 Duplicating lines in a cgen config saved to datamap.xml
+CAY-2731 Exception when setting a CLOB on H2 v2.0.202
 
 ----------------------------------
 Release: 4.2.B1

[cayenne] 01/02: fix H2 clob streaming

Posted by nt...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ntimofeev pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cayenne.git

commit 47b5fab7db7eb7dfe141a170cad67ac4ab727579
Author: Nigel Huband <nh...@gmail.com>
AuthorDate: Thu Jan 27 05:25:06 2022 +0300

    fix H2 clob streaming
---
 .../java/org/apache/cayenne/dba/h2/H2Adapter.java  | 14 ++++++++
 .../java/org/apache/cayenne/dba/h2/H2CharType.java | 38 ++++++++++++++++++++++
 2 files changed, 52 insertions(+)

diff --git a/cayenne-server/src/main/java/org/apache/cayenne/dba/h2/H2Adapter.java b/cayenne-server/src/main/java/org/apache/cayenne/dba/h2/H2Adapter.java
index 04a04c7..128321b 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/dba/h2/H2Adapter.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/dba/h2/H2Adapter.java
@@ -23,6 +23,7 @@ import org.apache.cayenne.access.DataNode;
 import org.apache.cayenne.access.sqlbuilder.sqltree.SQLTreeProcessor;
 import org.apache.cayenne.access.types.ExtendedType;
 import org.apache.cayenne.access.types.ExtendedTypeFactory;
+import org.apache.cayenne.access.types.ExtendedTypeMap;
 import org.apache.cayenne.access.types.ValueObjectTypeRegistry;
 import org.apache.cayenne.configuration.Constants;
 import org.apache.cayenne.configuration.RuntimeProperties;
@@ -83,6 +84,19 @@ public class H2Adapter extends JdbcAdapter {
         return query.createSQLAction(new H2ActionBuilder(node));
     }
 
+    /**
+     * Installs appropriate ExtendedTypes as converters for passing values
+     * between JDBC and Java layers.
+     * @since 4.1.2
+     */
+    @Override
+    protected void configureExtendedTypes(ExtendedTypeMap map) {
+        super.configureExtendedTypes(map);
+
+        // create specially configured CharType handler
+        map.registerType(new H2CharType());
+    }
+
     @Override
     protected PkGenerator createPkGenerator() {
         return new H2PkGenerator(this);
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/dba/h2/H2CharType.java b/cayenne-server/src/main/java/org/apache/cayenne/dba/h2/H2CharType.java
new file mode 100644
index 0000000..edfcc11
--- /dev/null
+++ b/cayenne-server/src/main/java/org/apache/cayenne/dba/h2/H2CharType.java
@@ -0,0 +1,38 @@
+package org.apache.cayenne.dba.h2;
+
+import org.apache.cayenne.access.types.CharType;
+
+import java.sql.Clob;
+import java.sql.PreparedStatement;
+import java.sql.Types;
+
+/**
+ * H2 specific char type handling - used to handle the correct setting of clobs
+ *
+ * @since 4.1.2
+ */
+public class H2CharType extends CharType {
+
+    public H2CharType() {
+        super(true, true);
+    }
+
+    @Override
+    public void setJdbcObject(PreparedStatement st, String val, int pos, int type, int precision) throws Exception {
+
+        if (type == Types.CLOB) {
+
+            if (isUsingClobs()) {
+
+                Clob clob = st.getConnection().createClob();
+                clob.setString(1, val);
+                st.setClob(pos, clob);
+
+            } else {
+                st.setString(pos, val);
+            }
+        } else {
+            st.setObject(pos, val);
+        }
+    }
+}