我想添加一个附件实体,我将从多个不同的实体中引用它,但它没有引用这些实体,我如何让它在 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;
}
有人可以指着我笑,告诉我为什么我做错了,我在这里误解了什么。谢谢。