Reputation: 357
I read all documentation about orm lite, also looking on net but didn't find right answers. I want to execute this statement:
SELECT * from Drive where day_number=150;
I have class that represent table:
@DatabaseTable(tableName="Drive")
public class Drive{
@DatabaseField(generatedId=true)
private int drive_id;
@DatabaseField
private String start_time;
@DatabaseField
private String end_time;
@DatabaseField
private String price;
@DatabaseField
private String distance;
@DatabaseField
private String day_number;
@DatabaseField
private String week_number;
@DatabaseField
private String month;
getters and setters ...
}
When i run:
List<Drive> today = getHelper().getVoznjaDao().queryBuilder().where().
eq("day_number","150").query();
I get NullPointerExeption
, and it's not because there is no record for 150 in database.
Please help i am desperate.
Upvotes: 0
Views: 4358
Reputation: 116908
Your code looks fine in terms of the query-builder logic. I suspect that something to do with your wiring is incorrect however. In your comments you mention that the NPE happens on the query line.
List<Drive> today = getHelper().getVoznjaDao().queryBuilder().where().
eq("day_number","150").query();
Most likely this means that either:
getHelper()
is returning a null
helper instancegetVoznjaDao()
is returning a null
DAOtoday
being null
would not cause a NPE since it is not dereferenced on the line. Certainly a bug in ORMLite is not out of the question but I would first check with a debugger to see if the getHelper()
or getVoznjaDao()
calls are returning null
. I suspect you will find the bug at that point.
Upvotes: 1