Buggy code:
public class TestGenericQuery extends TestCase { private static final DatabaseConnection DATABASE_CONNECTION1 = new DatabaseConnection ( "database1" ) ; public void test ( ) throws IOException , SQLException { IDatabases dbs = new com . rapleaf . jack . test_project . DatabasesImpl ( TestGenericQuery . DATABASE_CONNECTION1 ) ; IUserPersistence users = dbs . getDatabase1 ( ) . users ( ) ; ICommentPersistence comments = dbs . getDatabase1 ( ) . comments ( ) ; users . deleteAll ( ) ; comments . deleteAll ( ) ; User userA = users . createDefaultInstance ( ) . setHandle ( "A" ) . setBio ( "Football<seq2seq4repair_space>Coach" ) . setNumPosts ( 10 ) ; User userB = users . createDefaultInstance ( ) . setHandle ( "B" ) . setBio ( "Snowman<seq2seq4repair_space>Builder" ) . setNumPosts ( 30 ) ; User userC = users . createDefaultInstance ( ) . setHandle ( "C" ) . setBio ( "Spaceship<seq2seq4repair_space>Rider" ) . setNumPosts ( 20 ) ; User userD = users . createDefaultInstance ( ) . setHandle ( "D" ) . setBio ( "PDP-10<seq2seq4repair_space>Engineer" ) . setNumPosts ( 40 ) ; userA . save ( ) ; userB . save ( ) ; userC . save ( ) ; userD . save ( ) ; Comment commentA = comments . createDefaultInstance ( ) . setCommenterId ( ModelWithId . safeLongToInt ( userA . getId ( ) ) ) . setContent ( "comments" ) ; Comment commentB = comments . createDefaultInstance ( ) . setCommenterId ( ModelWithId . safeLongToInt ( userB . getId ( ) ) ) . setContent ( "comments" ) ; Comment commentC = comments . createDefaultInstance ( ) . setCommenterId ( ModelWithId . safeLongToInt ( userB . getId ( ) ) ) . setContent ( "comments" ) ; Comment commentD = comments . createDefaultInstance ( ) . setCommenterId ( ModelWithId . safeLongToInt ( userC . getId ( ) ) ) . setContent ( "comments" ) ; Comment commentE = comments . createDefaultInstance ( ) . setCommenterId ( ModelWithId . safeLongToInt ( userD . getId ( ) ) ) . setContent ( "comments" ) ; commentA . save ( ) ; commentB . save ( ) ; commentC . save ( ) ; commentD . save ( ) ; commentE . save ( ) ; <START_BUG> List < Map < ModelField , Object > > results = GenericQuery . create ( TestGenericQuery . DATABASE_CONNECTION1 ) . from ( User . class ) . join ( Comment . class , User . id ( ) , Comment . commenter_id ( ) ) . where ( User . bio ( ) , in ( Sets . newHashSet ( "Football<seq2seq4repair_space>Coach" , "Snowman<seq2seq4repair_space>Builder" , "Spaceship<seq2seq4repair_space>Rider" ) ) ) . where ( Comment . content ( ) , isNotNull ( ) ) . orderBy ( User . num_posts ( ) , DESC ) . orderBy ( Comment . id ( ) ) . select ( User . id ( ) , User . bio ( ) , User . handle ( ) , User . num_posts ( ) , Comment . id ( ) , Comment . commenter_id ( ) , Comment . content ( ) ) . fetch ( ) ; <END_BUG> for ( Map < ModelField , Object > record : results ) { System . out . println ( record . toString ( ) ) ; } } public void testBasicQuery ( IDatabases dbs ) throws IOException , SQLException { } }

Fix:
List < Map < ModelField , Object > > results = GenericQuery . create ( TestGenericQuery . DATABASE_CONNECTION1 ) . from ( User . class ) . leftJoin ( Comment . class , User . id ( ) , Comment . commenter_id ( ) ) . where ( User . bio ( ) , in ( Sets . newHashSet ( "Football<seq2seq4repair_space>Coach" , "Snowman<seq2seq4repair_space>Builder" , "Spaceship<seq2seq4repair_space>Rider" ) ) ) . where ( Comment . content ( ) , isNotNull ( ) ) . orderBy ( User . num_posts ( ) , DESC ) . orderBy ( Comment . id ( ) ) . select ( User . id ( ) , User . bio ( ) , User . handle ( ) , User . num_posts ( ) , Comment . id ( ) , Comment . commenter_id ( ) , Comment . content ( ) ) . fetch ( ) ;