【发布时间】:2015-02-17 10:30:48
【问题描述】:
我有一个关于 DTO 类表示的问题。我的数据库中有两张表,其中一张在另一张上有两个外键,例如:
book(id, author_name, author_age)
author(name, age, telephone)
其中书籍 author_name 和 author_age 是作者姓名和年龄的外键。
一般来说,在 DTO 类上实现这种情况的最佳方法是什么? 在 Book DTO 中,最好执行以下操作:
public class Book {
private String id;
private Author author;
}
或类似的东西
public class Book {
private String id;
private String author_name;
private int author_age;
}
?
【问题讨论】:
标签: mysql design-patterns dto