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:15:00 GMT
Repository: cayenne
Updated Branches:
  refs/heads/master fe43288be -> 01815158c


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/01815158
Tree: http://git-wip-us.apache.org/repos/asf/cayenne/tree/01815158
Diff: http://git-wip-us.apache.org/repos/asf/cayenne/diff/01815158

Branch: refs/heads/master
Commit: 01815158c9577e43318a808f78e359557ec3131a
Parents: fe43288
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:14:54 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/01815158/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 adcf71a..0af3ae6 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
@@ -455,7 +455,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/01815158/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/01815158/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 a76e0b3..9ac29b5 100644
--- a/docs/doc/src/main/resources/RELEASE-NOTES.txt
+++ b/docs/doc/src/main/resources/RELEASE-NOTES.txt
@@ -21,6 +21,7 @@ CAY-2379 Modeler: Visualization issue after an undo action for a deleted
ObjAttr
 CAY-2380 ReferenceMap should not store or return null values
 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.1.M1


Mime
View raw message