1

我的一个 OrmLite 类/表变得太大而无法自用,需要重构。我想把班级分开而不把桌子分开。

重构前:

@DatabaseTable(tableName = "Table") public class Employee {
   @DatabaseField(generatedId = true) final private int id;
   @DatabaseField final private String name;
   @DatanaseField final private String address;
}

重构后:

@DatabaseTable(tableName = "Table") public class Employee {
   @DatabaseField(generatedId = true) final private int id;
   @DatabaseField final private String name;
   @DatabaseField(foreign = true) final private Address;
}

@DatabaseTable(tableName = "Table") public class Address {
   @DatabaseField(generatedId = true) final private int id;
   @DatabaseField final private String address;
}

这会起作用还是我必须拆分表才能使用外部字段?

4

0 回答 0