Skip to content

Commit

Permalink
Fixed problem with the query builder and caches
Browse files Browse the repository at this point in the history
  • Loading branch information
Gray Watson committed Jul 28, 2016
1 parent be06ab1 commit a843e8d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/j256/ormlite/stmt/QueryBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ String getSelectColumnsAsString() {
*/
public PreparedQuery<T> prepare() throws SQLException {
// we only store things in the cache if there was not selects specified
boolean cacheStore = (resultFieldTypes == tableInfo.getFieldTypes());
boolean cacheStore = (selectList == null);
return super.prepareStatement(limit, cacheStore);
}

Expand Down
7 changes: 6 additions & 1 deletion src/test/java/com/j256/ormlite/dao/BaseObjectCacheTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,13 @@ public void testQueryAll() throws Exception {

List<Foo> results = dao.queryForAll();
assertEquals(1, results.size());
assertEquals(foo.id, results.get(0).id);
assertNotSame(foo, results.get(0));

Foo foo2 = dao.queryForId(foo.id);
assertNotNull(foo2);
assertEquals(foo.id, results.get(0).id);
assertSame(results.get(0), foo2);

}

@Test
Expand Down Expand Up @@ -270,6 +271,7 @@ protected static class NoId {
int notId;
@DatabaseField
String stuff;

public NoId() {
}
}
Expand All @@ -279,6 +281,7 @@ protected static class WithId {
int id;
@DatabaseField
String stuff;

public WithId() {
}
}
Expand All @@ -288,6 +291,7 @@ protected static class Parent {
int id;
@DatabaseField(foreign = true, foreignAutoRefresh = true)
Child child;

public Parent() {
}
}
Expand All @@ -297,6 +301,7 @@ protected static class Child {
int id;
@ForeignCollectionField
ForeignCollection<Parent> parents;

public Child() {
}
}
Expand Down

0 comments on commit a843e8d

Please sign in to comment.