DOM4J 和 Hibernate:处理 XML

发布于 2024-09-13 06:01:35 字数 414 浏览 1 评论 0原文

因此,我的 Web 应用程序主要使用 XML 进行客户端与服务器的交互,并且我目前使用 hibernate 来保留大部分后端。我知道有 XML 数据库,您可以通过使用 DOM4J 实体调用会话来使用 hibernate 保存 XML,但我不确定提供 XML 的最有效方法到底是什么。每次请求一个对象时,我都会从对象字段生成一个 XML 文档,然后提供它。因此,对于每个新请求,我都会生成一个全新的 XML 文档。因此,我可以在第一次请求时在每个运行时周期内为每个文档生成 XML,然后将其存储在对象的字段中,这样我就可以针对它运行 XSLT 命令,但这似乎效率低下。我猜测每次请求资源时生成一个新的 Document 对象,然后在请求得到服务后将其删除(并使用 Hibernate 查询语言进行选择)会更有效...或者我应该使用 Hibernate 或 eXist 保留 xml ?(我真的不想使用xml数据库!)

So my web application is primarily using XML for client to server interaction and I'm currently persisting most of my backend using hibernate. I know there are XML databases and there that you can save XML using hibernate by invoking Sessions with the DOM4J entity but I'm not sure what the most efficient way of serving up the XML really is. At the moment each time an object is request I generate an XML document from the object fields then serve it up. So for each new request I generate a whole new XML document. So I could generate the XML for each document during each runtime cycle the first time it is requested then store it in a field for the object so I can then run XSLT command against it but this seems kind of inefficient. I'm guessing its more efficient to generate a new Document object each time the resource is request and then drop it after the request has been served(and use Hibernate Query Language for selection)... Or should I persist xml using Hibernate or eXist?(I really don't want to use an xml database!)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

你穿错了嫁妆 2024-09-20 06:01:35

您可以将 XML 作为 CLOB 或 BLOB 存储在数据库中。如果查询时不需要查看文档内部,则只需外部化关键字段并基于这些字段查询 XML 即可。

You can store the XML as a CLOB or BLOB in the database. If you don't need to look inside the document when you query, you can just externalize the key fields and query for the XML based on those.

べ繥欢鉨o。 2024-09-20 06:01:35

关系数据库的主要目的之一是避免重复。如果您有在文档之间共享的对象,并且将其以 XML 形式存储在每个文档中,则在更改共享对象时必须更新所有文档。

使用 hibernate 以正常关系方式存储文档对象字段,并使用一些 XML 编组器将其转换为 XML 并返回,这是相当标准的做法,例如 xstream 或 CXF。

One of the main purposes of a relational database is to avoid duplication. If you have objects that are shared between documents, and you store that in XML in each document, you'd have to update all documents when you change the shared object.

It is pretty standard practice to store your document object fields in a normal relational way using hibernate, and use some XML marshaller to convert it to XML and back, e.g. xstream or CXF.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文