Search in sources :

Example 1 with RuntimeExceptionDao

use of com.j256.ormlite.dao.RuntimeExceptionDao in project ormlite-android by j256.

the class OrmLiteSqliteOpenHelper method getRuntimeExceptionDao.

/**
 * Get a RuntimeExceptionDao for our class. This uses the {@link DaoManager} to cache the DAO for future gets.
 *
 * <p>
 * NOTE: This routing does not return RuntimeExceptionDao&lt;T, ID&gt; because of casting issues if we are assigning
 * it to a custom DAO. Grumble.
 * </p>
 */
public <D extends RuntimeExceptionDao<T, ?>, T> D getRuntimeExceptionDao(Class<T> clazz) {
    try {
        Dao<T, ?> dao = getDao(clazz);
        @SuppressWarnings({ "unchecked", "rawtypes" }) D castDao = (D) new RuntimeExceptionDao(dao);
        return castDao;
    } catch (SQLException e) {
        throw new RuntimeException("Could not create RuntimeExcepitionDao for class " + clazz, e);
    }
}
Also used : SQLException(java.sql.SQLException) RuntimeExceptionDao(com.j256.ormlite.dao.RuntimeExceptionDao)

Aggregations

RuntimeExceptionDao (com.j256.ormlite.dao.RuntimeExceptionDao)1 SQLException (java.sql.SQLException)1