cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject [4/4] cayenne git commit: CAY-2086 SelectById.selectFirst stack overflow
Date Tue, 24 May 2016 09:26:59 GMT
CAY-2086 SelectById.selectFirst stack overflow


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

Branch: refs/heads/master
Commit: 89a46e1aaf20f65a9f6dfe84df01838126534487
Parents: 51e7223
Author: Andrus Adamchik <andrus@objectstyle.com>
Authored: Tue May 24 12:25:11 2016 +0300
Committer: Andrus Adamchik <andrus@objectstyle.com>
Committed: Tue May 24 12:26:48 2016 +0300

----------------------------------------------------------------------
 .../main/java/org/apache/cayenne/query/SelectById.java | 10 +---------
 .../org/apache/cayenne/query/SelectById_RunIT.java     | 13 +++++++++++++
 2 files changed, 14 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/89a46e1a/cayenne-server/src/main/java/org/apache/cayenne/query/SelectById.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/query/SelectById.java b/cayenne-server/src/main/java/org/apache/cayenne/query/SelectById.java
index f9e8209..6db4fa9 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/query/SelectById.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/query/SelectById.java
@@ -134,22 +134,14 @@ public class SelectById<T> extends IndirectQuery implements Select<T>
{
 		return context.select(this);
 	}
 
-	/**
-	 * Since we are selecting by ID, multiple matched objects likely indicate a
-	 * database referential integrity problem.
-	 */
 	@Override
 	public T selectOne(ObjectContext context) {
 		return context.selectOne(this);
 	}
 
-	/**
-	 * Since we are selecting by ID, we don't need to limit fetch size. Multiple
-	 * matched objects likely indicate a database referential integrity problem.
-	 */
 	@Override
 	public T selectFirst(ObjectContext context) {
-		return selectFirst(context);
+		return context.selectFirst(this);
 	}
 
 	@Override

http://git-wip-us.apache.org/repos/asf/cayenne/blob/89a46e1a/cayenne-server/src/test/java/org/apache/cayenne/query/SelectById_RunIT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/query/SelectById_RunIT.java b/cayenne-server/src/test/java/org/apache/cayenne/query/SelectById_RunIT.java
index ca3c5c5..89b889c 100644
--- a/cayenne-server/src/test/java/org/apache/cayenne/query/SelectById_RunIT.java
+++ b/cayenne-server/src/test/java/org/apache/cayenne/query/SelectById_RunIT.java
@@ -85,6 +85,19 @@ public class SelectById_RunIT extends ServerCase {
 		assertNotNull(a2);
 		assertEquals("artist2", a2.getArtistName());
 	}
+	
+	@Test
+	public void testIntPk_SelectFirst() throws Exception {
+		createTwoArtists();
+
+		Artist a3 = SelectById.query(Artist.class, 3).selectFirst(context);
+		assertNotNull(a3);
+		assertEquals("artist3", a3.getArtistName());
+
+		Artist a2 = SelectById.query(Artist.class, 2).selectFirst(context);
+		assertNotNull(a2);
+		assertEquals("artist2", a2.getArtistName());
+	}
 
 	@Test
 	public void testMapPk() throws Exception {


Mime
View raw message