我有这个抽象类:
域项
abstract public class DomainItem {
@DatabaseField(generatedId = true)
protected long id;
@ForeignCollectionField(eager = false)
protected ForeignCollection<ContentItem> contentItens;
//getters and setters
}
内容项:
abstract public class ContentItem {
@DatabaseField(generatedId = true)
protected long id;
@DatabaseField(foreign = true)
protected DomainItem domainItem;
@DatabaseField()
protected String content;
//getters and setters
}
还有这些(没有摘要):
@DatabaseTable()
public class PhytoterapicItem extends DomainItem{
public PhytoterapicItem(){
}
}
植物类成分
@DatabaseTable(tableName = "phytoterapiccontent")
public class PhytoterapicContent extends ContentItem {
@DatabaseField(canBeNull = false)
private String defaultName;
@DatabaseField(canBeNull = false)
private String scientificName;
//getters and setters
}
在我的 DatabaseHelper 中,我尝试创建表:
//DatabaseHelper
...
@Override
public void onCreate(SQLiteDatabase db, ConnectionSource connectionSource) {
try {
Log.i(TAG, "onCreate");
TableUtils.createTable(connectionSource, PhytoterapicContent.class);
Log.i(TAG, "Created table PhytoterapicContent");
TableUtils.createTable(connectionSource, PhytoterapicItem.class);
Log.i(TAG, "Created table PhytoterapicItem");
catch{
...
}
表 PhytoterapicContent 已创建。但我收到以下错误:
java.sql.SQLException:字段“contentItens”列名的外部集合类 br.com.project.model.ContentItem 不包含类 br.com.project.model.PhytoterapicItem 的外部字段