我有以下表格 -
@DatabaseTable(tableName="b", daoClass=B_DaoImpl.class)
public class B {
@DatabaseField
public String b1 ;
public B(){
// For Ormlite
}
}
@DatabaseTable(tableName="a", daoClass=A_DaoImpl.class)
public class A {
@DatabaseField
public String a1 ;
@DatabaseField(foreign=true)
public B b;
public A(){
// For Ormlite
}
}
对于这些表,关联的 Dao 和 DaoImpl 如下
public interface A_Dao extends Dao<A, String>{}
public interface B_Dao extends Dao<B, String>{}
public class B_DaoImpl extends BaseDaoImpl<User, String> implements B_Dao {
public B_DaoImpl(ConnectionSource connectionSource) throws SQLException {
super(connectionSource, B.class);
}
}
public class A_DaoImpl extends BaseDaoImpl<User, String> implements A_Dao {
public A_DaoImpl(ConnectionSource connectionSource) throws SQLException {
super(connectionSource, A.class);
}
}
数据库助手如下:
public class DatabaseHelperImpl extends OrmLiteSqliteOpenHelper implements DatabaseHelper {
private A_DaoImpl aDao = null;
private B_DaoImpl bDao = null;
public B_DaoImpl getBDao() throws SQLException {
if (bDao == null) {
bDao = getDao(B.class);
}
return bDao;
}
public A_DaoImpl getA() throws SQLException {
if (aDao == null ) {
aDao = getDao(A.class);
}
return aDao;
}
}
现在,当我尝试打电话时——
ADao aDao = databaseHelper.getA();
它出现以下错误:
Could not call the constructor in class class A_DaoImpl
现在,如果我在 A 中没有外键 - 即如果 A 不包含public B b,它可以正常工作。我在这里缺少什么吗?
非常感谢您提前。