【发布时间】:2020-05-06 19:03:37
【问题描述】:
您好,我正在使用两个表 student 和 student_address,在两个表中都有共同的列 id 作为 uid(在任何情况下都不能更改)
我正在使用 StudentAndAddress 类作为
public class StudentAndAddress{
@Embedded
private Student student;
@Embedded(prefix = "type_")
private StudentAddress studentAddress;
public Address getStudent() {
return student;
}
public void setStudent(Student student) {
this.student = student;
}
public StudentAddress getStudentAddress() {
return studentAddress;
}
public void setStudentAddress(StudentAddress studentAddress) {
this.studentAddress = studentAddress;
}
}
我使用的查询是:
@Query("SELECT * FROM student INNER JOIN student_address ON student.uid == student_address.address_uid and address_link.linkto_type==:linkToType")
LiveData<List<StudentAndAddress>> getStudentAndAddress(String linkToType);
我得到了第一个表的值,但没有得到第二个表的值。 在数据库中,两个表都存在
【问题讨论】:
标签: android spring-boot orm android-sqlite android-room