finaldb保存关联对象

httpsnail 发布于 2013/11/04 09:55
阅读 395
收藏 0

@michaely 你好,想跟你请教个问题:

在用final对象保存的时候类中的对象好像不能保存,

比如


public class Question implements Serializable{
@Transient
private static final long serialVersionUID = 2880643702469043457L;
private int id;
private int _id;
public int get_id() {
return _id;
}
public void set_id(int _id) {
this._id = _id;
}

@ManyToOne
private Student student;
private Grade grade;
private Subject subject;
private int gold;
private String title;
private String picUrl;
private long createdTime;
private long weight;
private QuestionStatus status;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}


public Student getStudent() {
return student;
}
public void setStudent(Student student) {
this.student = student;
}
public Grade getGrade() {
return grade;
}
public void setGrade(Grade grade) {
this.grade = grade;
}
public Subject getSubject() {
return subject;
}
public void setSubject(Subject subject) {
this.subject = subject;
}
public int getGold() {
return gold;
}
public void setGold(int gold) {
this.gold = gold;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getPicUrl() {
return picUrl;
}
public void setPicUrl(String picUrl) {
this.picUrl = picUrl;
}
public long getCreatedTime() {
return createdTime;
}
public void setCreatedTime(long createdTime) {
this.createdTime = createdTime;
}
public long getWeight() {
return weight;
}
public void setWeight(long weight) {
this.weight = weight;
}
public QuestionStatus getStatus() {
return status;
}
public void setStatus(QuestionStatus status) {
this.status = status;
}
}


上面的类中我想保存student对象,我配置了@ManyToOne,可是我发现sqllite中只保存了student对象的id,请问是不是我那些地方用错了?

加载中
0
理工男海哥
理工男海哥
@ManyToOne 中,目前只用于查询,如果要保存的话,自己保存了Question,然后再手动保存student。
返回顶部
顶部