java - 如何放置正确的 DBFLow 注释

标签 java sqlite orm annotations mapping

我想将医生对象插入数据库,我应该如何为属性添加注解?
我试着用下面显示的代码来做到这一点。
但我不知道如何在列表属性 specializationsphoneNumbers 上做到这一点。

@Table(databaseName = WMDatabase.NAME)
public class Doctor extends BaseModel{

@Column
@PrimaryKey
@Unique(unique = true)
private String doctorId;

@Column
private FullName fullName;

@Column
private String organizationId;

@Column What shuld i put here?????
private List<Specialization> specializations;

@Column What shuld i put here?????    
private Contacts contacts;
}

以下是我用于医生属性的类:

public class Contacts extends BaseModel {

private List<PhoneNumber> phoneNumbers;
private String email;
private String fax;
}

public class Specialization extends BaseModel {

@Column
@PrimaryKey
@Unique(unique = true)
private String doctorId;

@Unique(unique = true)
private String specializationName;

public String getSpecializationName() {
    return specializationName;
}

public void setSpecializationName(String specializationName) {
    this.specializationName = specializationName;
}

最佳答案

根据文档 here,DBFlow 是一个关系数据库系统(不是 mongo 类型的键/值存储)并且不支持列表作为列。 .

List : List columns are not supported and not generally proper for a relational database. However, you can get away with a non-generic List column via a TypeConverter. But again, avoid this if you can.

关于 relationships 的文档可以帮助您改进模型以满足您的需要。

关于java - 如何放置正确的 DBFLow 注释,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31807487/

相关文章:

django/celery : Best practices to run tasks on 150k Django objects?

java - 如何使字段成为 BLOB 而不是 TINYBLOB?

java - 用于 Java 的快速、易学且对 POJO 友好的 ORM?

java - JNI - 将 STDOUT 连接到 JTextArea?

iphone - 从应用程序将图片/图像存储在 SQLite DB 中是个好主意吗?

iphone - JSON 值未保存到 iPhone 中的 SQLite 数据库

database - 如何在 Mac OS X 应用程序中播种数据库

java - 如何查看数组列表是否已填充

c# - 偶尔接收到的TCP数据顺序错误,不完整

java - 四舍五入将其转换为 int (java)