You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
By default, most of the DAO methods throw SQLException which is the default internal exception for most JDBC and other SQL calls. But in Android-land, especially, most of the exceptions extend RuntimeException so having to put a lot of ignored try ... catch stanzas is inconvenient.
For this reason we’ve added a RuntimeExceptionDao which wraps all calls to the underlying DAO to rethrow the SQL exceptions as runtime exceptons.
I think the @OrmliteDao annotation should handle this. The annotated field type could be Dao or RuntimExceptionDao (currently only Dao is accepted), and according to this type, the relevant constructor will be used to assign the field.
I was wondering why not use databaseHelper_.getRuntimeExceptionDao(Entity.class) instead of using
RuntimeExceptionDao.createDao(databaseHelper_.getConnectionSource(), Entity.class).
The method without RuntimeException is already using databaseHelper_.getDao(Entity.class)
I can't cast my object that extends from RuntimeExceptionDao<Entity, Integer>
Same remark is put in the Javadoc for the getDao...
My code worked well when using @OrmLiteDao annotations on custom dao classes extending from BaseDaoImpl
getDao
public <D extends com.j256.ormlite.dao.Dao<T,?>,T> D getDao(Class clazz)
throws SQLException
Get a DAO for our class. This uses the DaoManager to cache the DAO for future gets.
NOTE: This routing does not return Dao because of casting issues if we are assigning it to a custom DAO. Grumble.
For me it's working fine usign getDao. Injection worked perfectly well.
I don't understand why the javadoc state that... ?
And when I'm trying to use @OrmliteDao on a RuntimeExceptionDao, I end up with a casting problem when generating the file. The compiler refuses to cast.
entityDao = RuntimeExceptionDao.createDao(databaseHelper_.getConnectionSource(), Entity.class); ---> produce the compilation error
My EntityDao classed is defined as :
public class EntityDao extends RuntimeExceptionDao<Entity, Integer> {
public EntityDao(Dao<Entity, Integer> dao) {
super(dao);
}
}
As mentionned in the ormlite documentation :
I think the
@OrmliteDaoannotation should handle this. The annotated field type could beDaoorRuntimExceptionDao(currently onlyDaois accepted), and according to this type, the relevant constructor will be used to assign the field.