开发者

DOM4J and Hibernate: Dealing with the XML

开发者 https://www.devze.com 2023-01-10 04:56 出处:网络
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 sa

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!)


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消