MVC。实施模型布局。我的最终解决方案。成功?
在开始实施模型布局之前,我在此网站上问几个问题:
和
用户给了我很多好的、完美的推荐。
结果,我为模型布局创建了下一个实现:
您能看一下我的屏幕截图吗?并告诉我,
我正确理解了一切? 我的实施成功了吗?
兰格图像上的PS链接:http://www.dropmocks.com/mBf62w
Before start work on implementation Model layout, I ask few question on this site:
Correct design for entity classes. Need recommendations
Java Generics. What benefit in my case?
and
Two classes with almost duplicate code inside
Users give me many good and perfect recommendations.
In result, I create next implementation for my Model Layout:
Can you please look on my screenshot. And tell me,
I correct understang all?
And my implementation success?
P.S. link on lange image: http://www.dropmocks.com/mBf62w
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当我使用 hibernate 时,我不关心 dao,似乎没有必要/多余,只有实体和服务层(以及控制器和视图)。
然而,对于这个。
I don't bother with a dao when I use hibernate, seems unnecessary/superfluous and just have entities and a service layer (and a controller and view).
There are however differing views on this.
您的解决方案还缺少一件事,那就是服务层。这很重要,因为您将在服务层中使用 DAO 来执行某些业务逻辑。通常数据库事务也在服务层上定义,因此请记住这一点。
我还会摆脱
Persistent
接口,因为我看不出它有什么帮助,相反 - 我会使用PersistentImpl
的抽象类。那么AbstractEntity
会是更合适的名称。除此之外 - 你的解决方案整洁干净 - 我在我的几个项目中使用它,我对此非常满意:)
Your solution lacks of one more thing, which is Service Layer. This is important, since you will use DAOs within the service layer to perform some business logic. Usually Database Transactions are also defined on the service layer, so keep that in mind.
I would also get rid of
Persistent
interface, since I don't see how it helps in anything, and instead - I would use abstract class forPersistentImpl
.AbstractEntity
would be more appropriate name then.Other than that - your solution is neat and clean - I'm using it across several project of mine and I'm very happy with it :)