多少数据对象层是一个好的实践?
我们有一个中型 Java 服务器,其数据按以下方式流动:
SQL 数据库 ->数据层->业务层-> XML 序列化
值得注意的是,数据模型在各层之间大多不会改变。然而我被告知,将单一数据模型用作: SQL 数据库 -- (IBATIS) -->型号->将模型转换为 XML - 不是一个好主意,因为模式更改意味着模型中的更改,然后应用程序中所有层的更改。 XML 的变化也意味着模型必须改变。
那么在这种情况下是否建议有两个对象层? 1) 业务模式使用 IBatis 映射到的业务逻辑数据层。 2) JAXB 用于转换为 XML 的 XML 层。
We have a medium sized Java server that has data flowing in the following way:
SQL Database -> Data Layer -> Business Layer -> XML Serialization
It's important to note, that the data model mostly does not change between the layers. Yet I have been told that having a single data model used as:
SQL Database -- (IBATIS) -> Model -> convert the model to XML - is not a good idea, since schema changes mean changes in the model and then change in all layers in the application. And XML changes also mean the model has to change.
So is it recommended to have two object layers in this case? 1) Business logic data layer that the business schema maps to using IBatis. 2) XML layer that JAXB uses to convert to XML.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
注意:我领导 EclipseLink JAXB (MOXy) 和 EclipseLink提供 JAXB 和 JPA 实现。
我建议使用一种通过 JAXB 映射到 XML 并通过 JPA 映射到数据库的数据模型。
Note: I lead EclipseLink JAXB (MOXy), and EclipseLink provides both JAXB and JPA implementations.
I recommend using one data model that is mapped to XML via JAXB, and to the database via JPA.
总的来说:是的,最好有一个单独的模型。
聚苯乙烯
由于在您的问题中您将其称为图层,因此您可能喜欢以下卡通: http://geekandpoke.typepad.com/geekandpoke/2011/03/architectural-best-practices.html
别太认真了:)
In general: yes, it's better to have a separate models.
P.S.
Since in your question you called it layers, you may like the following cartoon: http://geekandpoke.typepad.com/geekandpoke/2011/03/architectural-best-practices.html
Don't take it too seriously :)