我的要求是将巨大的XML值保存到数据库。 在分析了几个选项之后,我最终确定了从巨大的xml生成实体bean类,然后使用hibernate对其进行持久化的过程。 我不选择创建hbm文件,而是选择hibernate注释。这样,我将使用JAXB从XSD生成Java类,并手动添加hibernate注释。 是否有任何eclipse插件或util框架可以使用默认的hibernate注释从XSD生成实体类?
这里是一些文档:
http://confluence.highsource.org/display/HJ3/Making+schema- derived+classes+ready+for+JPA
http://java.net/projects/hyperjaxb
这是我已完成的项目的工作示例:
<plugin> <groupId>org.jvnet.jaxb2.maven2</groupId> <artifactId>maven-jaxb2-plugin</artifactId> <version>0.7.4</version> <dependencies> <dependency> <groupId>org.jvnet.hyperjaxb3</groupId> <artifactId>hyperjaxb3-ejb-plugin</artifactId> <version>0.5.5</version> </dependency> </dependencies> <executions> <execution> <id>generate-domain1</id> <goals> <goal>generate</goal> </goals> <configuration> <strict>false</strict> <schemaIncludes> <value>account.xsd</value> <value>customer.xsd</value> <value>address.xsd</value> </schemaIncludes> <bindingIncludes> <include>domain-bindings.xjb</include> </bindingIncludes> <extension>true</extension> <generatePackage>your.package.here</generatePackage> <generateDirectory>${project.build.directory}/generated-sources/jaxbandjpa</generateDirectory> <args> <arg>-Xannotate</arg> <arg>-Xhyperjaxb3-ejb</arg> </args> <plugins> <plugin> <groupId>org.jvnet.jaxb2_commons</groupId> <artifactId>jaxb2-basics</artifactId> <version>0.6.0</version> </plugin> <plugin> <groupId>org.jvnet.jaxb2_commons</groupId> <artifactId>jaxb2-basics-annotate</artifactId> <version>0.6.0</version> </plugin> </plugins> </configuration> </execution> </executions> </plugin>
希望能帮助到你