码:
@Entity(tableName = "UserRepo", indices = @Index(value = "id", unique = true))
public class GitHubRepo {
@PrimaryKey(autoGenerate = true)
public int _id;
public int id;
public String name;
public String description;
@Embedded
public RepoOwner owner;
public GitHubRepo(int id, String name, String description, RepoOwner owner) {
this.id = id;
this.name = name;
this.description = description;
this.owner = owner;
}
public class RepoOwner {
@ColumnInfo(name = "user_id")
public int id;
public String login;
public RepoOwner(int id, String login) {
this.id = id; …Run Code Online (Sandbox Code Playgroud)