本文主要是介绍LitePal一对一、多对一、多对多,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
参考:https://www.jianshu.com/p/bc68e763c7a2
一对一
一个boy对应一个girl,相应地一个girl对应一个boy
Boy类:
public class Boy extends DataSupport {private int id;private Girl girl;private String name;private int age;public int getId() {return id;}public void setId(int id) {this.id = id;}public Girl getGirl() {return girl;}public void setGirl(Girl girl) {this.girl = girl;}public String getName() {return name;}public void setName(String name) {this.name = name;}public int getAge() {return age;}public void setAge(int age) {this.age = age;}@Overridepublic String toString() {return "Boy{" +"id=" + id +", girl=" + girl +", name='" + name + '\'' +", age=" + age +'}';}
}
Girl类
public class Girl extends DataSupport {
private int id;
private Boy boy;
private int age;
private String name;public Boy getBoy() {return boy;
}public void setBoy(Boy boy) {this.boy = boy;
}public int getAge() {return age;
}public void setAge(int age) {this.age = age;
}public String getName() {return name;
}public void setName(String name) {this.name = name;
}public int getId() {return id;
}public void setId(int id) {this.id = id;
}@Override
public String toString() {return "Girl{" +"id=" + id +", boy=
这篇关于LitePal一对一、多对一、多对多的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!