Skip to content

Commit a843e8d

Browse files
author
Gray Watson
committed
Fixed problem with the query builder and caches
1 parent be06ab1 commit a843e8d

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/main/java/com/j256/ormlite/stmt/QueryBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ String getSelectColumnsAsString() {
9898
*/
9999
public PreparedQuery<T> prepare() throws SQLException {
100100
// we only store things in the cache if there was not selects specified
101-
boolean cacheStore = (resultFieldTypes == tableInfo.getFieldTypes());
101+
boolean cacheStore = (selectList == null);
102102
return super.prepareStatement(limit, cacheStore);
103103
}
104104

src/test/java/com/j256/ormlite/dao/BaseObjectCacheTest.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,12 +164,13 @@ public void testQueryAll() throws Exception {
164164

165165
List<Foo> results = dao.queryForAll();
166166
assertEquals(1, results.size());
167+
assertEquals(foo.id, results.get(0).id);
167168
assertNotSame(foo, results.get(0));
168169

169170
Foo foo2 = dao.queryForId(foo.id);
170171
assertNotNull(foo2);
172+
assertEquals(foo.id, results.get(0).id);
171173
assertSame(results.get(0), foo2);
172-
173174
}
174175

175176
@Test
@@ -270,6 +271,7 @@ protected static class NoId {
270271
int notId;
271272
@DatabaseField
272273
String stuff;
274+
273275
public NoId() {
274276
}
275277
}
@@ -279,6 +281,7 @@ protected static class WithId {
279281
int id;
280282
@DatabaseField
281283
String stuff;
284+
282285
public WithId() {
283286
}
284287
}
@@ -288,6 +291,7 @@ protected static class Parent {
288291
int id;
289292
@DatabaseField(foreign = true, foreignAutoRefresh = true)
290293
Child child;
294+
291295
public Parent() {
292296
}
293297
}
@@ -297,6 +301,7 @@ protected static class Child {
297301
int id;
298302
@ForeignCollectionField
299303
ForeignCollection<Parent> parents;
304+
300305
public Child() {
301306
}
302307
}

0 commit comments

Comments
 (0)