i am using ormlite version 4.46 I am able to get the desired result when i run a raw query but somehow the result is null when i am trying it in ormlite can someone please explain where i am making a mistake.
Snippet:
String query=
"SELECT Products.* FROM "+DBConst.TABLE_PRODUCTS
+" INNER JOIN "+DBConst.TABLE_OFFERS_MAPPING
+" ON Products."+DBConst.PROD_ID+" = OffersMapping."+DBConst.OFFERS_PRODUCT_ID
+" WHERE "+DBConst.OFFERS_OFFER_ID+ " = "+offerId+
" GROUP BY "+DBConst.PROD_PARENT_PRODVAR_ID;
GenericRawResults<Product> rawResults = productDao.queryRaw(query, productDao.getRawRowMapper());
//produces this query:SELECT Products.* FROM Products INNER JOIN OffersMapping ON Products._id = OffersMapping.product_id WHERE offer_id = 141 GROUP BY variant_id
List<Product> prodList = rawResults.getResults();
rawResults.close();
Gives me desired result.... Now to ormlite
Dao<Product, String> productDao = helper.getProductDao();
Dao<OfferMapping, String> offerMappingDao = helper.getOfferMappingDao();
try {
QueryBuilder<Product, String> productQb = productDao.queryBuilder();
QueryBuilder<OfferMapping, String> offerQb = offerMappingDao.queryBuilder();
//to sort the offer id accordingly
offerQb.where().eq(DBConst.OFFERS_OFFER_ID, offerId);
productQb.where().eq(DBConst.PROD_ID, new ColumnArg(DBConst.OFFERS_PRODUCT_ID));
productQb.join(offerQb);
productQb.groupBy(DBConst.PROD_PARENT_PRODVAR_ID);
Constants.showLog("Query", "Query is "+productQb.query());//gets null here
List<Product> prodList = productQb.query();
} catch (SQLException e) {
e.printStackTrace();
}
return null;
Dont know where i am making a mistake...