将XML结构映射到数据库模式 [英] Map XML structure to database schema
问题描述
我问这个原因是因为我的数据在XML结构方面是最好的描述。但是,我想将它们存储在数据库中以获得快速的查询结果和其他好处。
我在一个Java项目中一些要求,我们发现 HyperJAXB 非常适合。它使用JAXB从XML模式获取到Java对象,然后使用Hibernate来持久化Java对象。最新版本适用于支持EJB3 / JPA的任何东西。
通常情况下,它不会生成数据库模式文件,但是如果需要,可以使Hibernate吐出来它。因为模式自动生成它可能会看起来有点丑陋,直到你解决为什么它的完成方式。
如果你不使用Java,但你会是愿意使用与HQL(Hibernate Query Language)类似的东西来访问数据库,因此您可以使用它将XSD设置为DDL转换器,因为生成的模式是使用HQL样式操作创建的。如果这听起来不够丑陋,你可以调出hibernate日志记录,看看它为各种HQL查询生成了什么SQL,并使用它来确保你正确的访问模式。
所以基本上这不是很适合任何东西,但Java:)
Is there a tool that directly maps XML structure to database schema?
The reason I ask this is because my data is best described in terms of XML structure. However, I want to store them in database for fast query result and other benefits.
I was on a Java project that had the some requirements and we found that HyperJAXB was a good fit. It uses JAXB to get from the XML schema to Java objects and then uses Hibernate to persist the Java objects. The latest version works with anything that supports EJB3/JPA as well.
Normally it does this without producing the database schema file but you can make Hibernate spit it out if you need it. Because the schema automatically produced it can look a little ugly until you work out why it's done the way it's done.
If you aren't using Java but you'd be willing to use something similar to HQL (Hibernate Query Language) to access the database then you could use it to make an XSD to DDL converter since the generated schema is created with HQL style operations in mind. If that doesn't sound ugly enough you could turn up the hibernate logging and see what SQL it generates for various HQL queries and use that to make sure that you're getting the access patterns right.
So basically it's not a good fit for anything but Java :)
这篇关于将XML结构映射到数据库模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!