【发布时间】:2012-02-23 09:53:07
【问题描述】:
使用 ormlite 的 android 项目中出现错误 我收到此代码的编译错误:
public class DatabaseModel {
private Dao<Object, Integer> mDao = null;
private DatabaseHelper mHelper;
private Class<?> mClass;
public DatabaseModel(DatabaseHelper h, Class<?> c) {
mHelper = h;
mClass = c;
try {
mDao = mHelper.getDao(mClass);
} catch (SQLException e) {
Debug.e("Can't get dao", e.getStackTrace());
throw new RuntimeException(e);
}
}
on line 25 mDao = mHelper.getDao(mClass);
Error: type parameters of <D>D cannot be determined; no unique maximal
instance exists for type variable D with upper bounds
com.j256.ormlite.dao.Dao<java.lang.Object,java.lang.Integer>,
com.j256.ormlite.dao.Dao<capture#296 of ?,?>
但是当我尝试使用 eclipse 构建项目时它工作正常
错误看起来类似于to this SO question。
不知道是Idea还是javac的这个bug。
我的配置: IntelliJ IDEA 11.0.2 构建 #IC-111.277 建立在 1 Февраль 2012 г. JDK:1.6.0_29 虚拟机:Java HotSpot(TM) 64 位服务器虚拟机 供应商:Apple Inc.
【问题讨论】:
-
我想看看
DatabaseHelper.getDao()方法。 -
当然!你可以从ormlite.com下载源代码
-
但是没有名为 DatabaseHelper 的类。
-
这是android包的一部分
标签: java android generics intellij-idea ormlite