我必须要表,并且在secend类上的索引是一个伪造的关键,我该如何在1类和2类中获取对象
我有这个:
@Entity(tableName = "director"/*,
indices = {@Index(value = "full_name", unique = true)}*/)
public class Director {
@PrimaryKey(autoGenerate = true)
@ColumnInfo(name = "did")
public int id;
@ColumnInfo(name = "full_name")
@NonNull
public String fullName;
@Entity(tableName = "movie",
foreignKeys = @ForeignKey(entity = Director.class,
parentColumns = "did",
childColumns = "directorId",
onDelete = ForeignKey.CASCADE),
indices = {@Index("title"), @Index("directorId")})
public class Movie {
@PrimaryKey(autoGenerate = true)
@ColumnInfo(name = "mid")
public int id;
@ColumnInfo(name = "title")
@NonNull
public String title;
@ColumnInfo(name = "directorId")
public int directorId;
当我拿完所有电影时,都会得到导演id。我应该怎么做才能产生这个:
public class MovieWithDirector {
Movie movie;
Director director;
}
我可以得到一个用户,以后再获得directerByID,但是现在这不是最好的方法,我现在不知道