John Ernest Guadalupe John Ernest Guadalupe - 4 months ago 8x
Java Question

I can't retrieve data from sqlite db using Ormlite?

My model has a

variable and I am able to save just fine.

But whenever I try to retrieve a row it throws this error:

Caused by: java.lang.IllegalArgumentException: field model.date_time_created has type
java.sql.Date, got java.util.Date
at java.lang.reflect.Field.set(Native Method)
at java.lang.reflect.Field.set(
at com.j256.ormlite.field.FieldType.assignField(
       at com.j256.ormlite.stmt.mapped.BaseMappedQuery.mapRow(
        at com.j256.ormlite.stmt.SelectIterator.getCurrent(
        at com.j256.ormlite.stmt.SelectIterator.nextThrow(
        at com.j256.ormlite.stmt.StatementExecutor.query(
        at com.j256.ormlite.stmt.StatementExecutor.queryForAll(
        at com.j256.ormlite.dao.BaseDaoImpl.queryForAll(

My method to get a list :

public List<Model> getModelList() {
try {
return getHelper().getModelDao().queryForAll();
} catch (SQLException e) {
return null;

Model is a placeholder


IllegalArgumentException: field model.date_time_created has type java.sql.Date, got java.util.Date

The problem turned out to be a bug in ORMLite. Under Android/SQLite we have to convert all dates to be strings and the conversion from java.sql.Date was broken. Switching to java.util.Date will work.

This will be fixed in version 5.0. See: