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.
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.
Most likely this means that either:
getHelper()is returning anullhelper instancegetVoznjaDao()is returning anullDAOtodaybeingnullwould 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 thegetHelper()orgetVoznjaDao()calls are returningnull. I suspect you will find the bug at that point.