【发布时间】:2015-01-23 12:35:53
【问题描述】:
我想添加一个附件实体,我将从多个不同的实体中引用它,但它没有引用这些实体,我如何在 ORMLite 中让它工作?
我不断收到此异常:
Caused by: java.sql.SQLException: Foreign collection class entity.Attachment for
field 'attachments' column-name does not contain a foreign field named
'attachmentId' of class enity.News
例如我有一个新闻实体
@DatabaseTable
public class News extends Record {
@DatabaseField(index = true, id = true)
private long newsArticleId;
@DatabaseField
private String subject;
@DatabaseField
private String content;
@ForeignCollectionField
Collection<Attachment> attachments;
}
附件实体:
@DatabaseTable
public class Attachment extends Record {
@DatabaseField(id = true, index = true)
private long attachmentId;
@DatabaseField
private String attachmentUrl;
}
有人能指点我笑一下,告诉我为什么我做错了,我在这里误解了什么。谢谢。
【问题讨论】:
标签: android ormlite foreign-collection