这更像是一个设计问题,所以我知道我会收到很多抨击,但我有点困惑。 在Dropwizard中,我们使用DAO对象来声明我们想要运行的SQL查询,使用Mapper将它们映射到对象。
现有结构:
- StudentPOJO
- StudentMapper for all StudentPOJO fields
- StudentDAO which has all the "select * from student where ..." calls.
改变 -
- StudentDAO now has to have a query that says "Selct a.*, b.name from student a, subjects b where ...."
- Now to get this information I need to
- make changes to both Mapper and POJO
OR
- create new Mapper and POJO (or extend the existing POJO and add the new params to the child POJO)
这种情况的通常规范是什么?这种情况的利弊是什么?