gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-30 10:59:44 24 4
gpt4 key购买 nike

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

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com