cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ntimof...@apache.org
Subject cayenne git commit: CAY-2387 Can't select byte[] property with ColumnSelect
Date Wed, 06 Dec 2017 07:16:31 GMT
Repository: cayenne
Updated Branches:
  refs/heads/STABLE-4.0 7cd30b821 -> 6a6cd0bfb


CAY-2387 Can't select byte[] property with ColumnSelect


Project: http://git-wip-us.apache.org/repos/asf/cayenne/repo
Commit: http://git-wip-us.apache.org/repos/asf/cayenne/commit/6a6cd0bf
Tree: http://git-wip-us.apache.org/repos/asf/cayenne/tree/6a6cd0bf
Diff: http://git-wip-us.apache.org/repos/asf/cayenne/diff/6a6cd0bf

Branch: refs/heads/STABLE-4.0
Commit: 6a6cd0bfbfddcab088cea09ec1e89ab38fa58e06
Parents: 7cd30b8
Author: Nikita Timofeev <stariy95@gmail.com>
Authored: Wed Dec 6 10:14:54 2017 +0300
Committer: Nikita Timofeev <stariy95@gmail.com>
Committed: Wed Dec 6 10:15:49 2017 +0300

----------------------------------------------------------------------
 .../select/DefaultSelectTranslator.java          |  2 +-
 .../org/apache/cayenne/query/ColumnSelectIT.java | 19 +++++++++++++++++++
 docs/doc/src/main/resources/RELEASE-NOTES.txt    |  1 +
 3 files changed, 21 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/6a6cd0bf/cayenne-server/src/main/java/org/apache/cayenne/access/translator/select/DefaultSelectTranslator.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/access/translator/select/DefaultSelectTranslator.java
b/cayenne-server/src/main/java/org/apache/cayenne/access/translator/select/DefaultSelectTranslator.java
index d35b0b4..bcb4c9b 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/access/translator/select/DefaultSelectTranslator.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/access/translator/select/DefaultSelectTranslator.java
@@ -460,7 +460,7 @@ public class DefaultSelectTranslator extends QueryAssembler implements
SelectTra
 				int type = getJdbcTypeForProperty(property);
 				ColumnDescriptor descriptor;
 				if(property.getType() != null) {
-					descriptor = new ColumnDescriptor(builder.toString(), type, property.getType().getName());
+					descriptor = new ColumnDescriptor(builder.toString(), type, property.getType().getCanonicalName());
 				} else {
 					descriptor = new ColumnDescriptor(builder.toString(), type);
 				}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/6a6cd0bf/cayenne-server/src/test/java/org/apache/cayenne/query/ColumnSelectIT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/query/ColumnSelectIT.java b/cayenne-server/src/test/java/org/apache/cayenne/query/ColumnSelectIT.java
index fe4edba..bf1a6d6 100644
--- a/cayenne-server/src/test/java/org/apache/cayenne/query/ColumnSelectIT.java
+++ b/cayenne-server/src/test/java/org/apache/cayenne/query/ColumnSelectIT.java
@@ -21,6 +21,7 @@ package org.apache.cayenne.query;
 
 import java.math.BigDecimal;
 import java.math.BigInteger;
+import java.sql.SQLException;
 import java.sql.Types;
 import java.text.DateFormat;
 import java.util.Date;
@@ -45,6 +46,7 @@ import org.apache.cayenne.test.jdbc.TableHelper;
 import org.apache.cayenne.testdo.testmap.Artist;
 import org.apache.cayenne.testdo.testmap.Gallery;
 import org.apache.cayenne.testdo.testmap.Painting;
+import org.apache.cayenne.testdo.testmap.PaintingInfo;
 import org.apache.cayenne.unit.PostgresUnitDbAdapter;
 import org.apache.cayenne.unit.UnitDbAdapter;
 import org.apache.cayenne.unit.di.server.CayenneProjects;
@@ -1074,4 +1076,21 @@ public class ColumnSelectIT extends ServerCase {
         }
     }
 
+    @Test
+    public void testByteArraySelect() throws SQLException {
+        new TableHelper(dbHelper, "PAINTING_INFO")
+                .setColumns("IMAGE_BLOB", "PAINTING_ID")
+                .setColumnTypes(Types.LONGVARBINARY, Types.INTEGER)
+                .insert(new byte[]{(byte)1, (byte)2, (byte)3, (byte)4, (byte)5}, 1)
+                .insert(new byte[]{(byte)5, (byte)4, (byte)3, (byte)2}, 2);
+
+        List<byte[]> blobs = ObjectSelect.columnQuery(PaintingInfo.class, PaintingInfo.IMAGE_BLOB)
+                .orderBy("db:" + PaintingInfo.PAINTING_ID_PK_COLUMN)
+                .select(context);
+
+        assertEquals(2, blobs.size());
+        assertArrayEquals(new byte[]{(byte)1, (byte)2, (byte)3, (byte)4, (byte)5}, blobs.get(0));
+        assertArrayEquals(new byte[]{(byte)5, (byte)4, (byte)3, (byte)2}, blobs.get(1));
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/6a6cd0bf/docs/doc/src/main/resources/RELEASE-NOTES.txt
----------------------------------------------------------------------
diff --git a/docs/doc/src/main/resources/RELEASE-NOTES.txt b/docs/doc/src/main/resources/RELEASE-NOTES.txt
index f79a402..dfa0524 100644
--- a/docs/doc/src/main/resources/RELEASE-NOTES.txt
+++ b/docs/doc/src/main/resources/RELEASE-NOTES.txt
@@ -23,6 +23,7 @@ CAY-2370 ValueObjectType for byte[] fails lookup
 CAY-2379 Modeler: Visualization issue after an undo action for a deleted ObjAttribute
 CAY-2382 Lack of synchronization in DataContext serialization
 CAY-2384 Modeler: Visualization issue after an undo action for a deleted ObjRelationship
+CAY-2387 Can't select byte[] property with ColumnSelect
 
 ----------------------------------
 Release: 4.0.B2


Mime
View raw message