Generate hibernate entity beans from XSD

前端 未结 2 1441
灰色年华
灰色年华 2021-02-06 06:00

My requirement is to save a huge XML values to database.
After analyzing few options I finalized that generate entity bean classes from huge xml and then persist it using h

相关标签:
2条回答
  • 2021-02-06 06:06

    Here's some documentation:

    http://confluence.highsource.org/display/HJ3/Making+schema-derived+classes+ready+for+JPA

    http://java.net/projects/hyperjaxb

    Here's a working example for a project I have completed:

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

    hope it helps

    0 讨论(0)
  • 2021-02-06 06:15

    You could use HyperJAXB to generate a JAXB model with JPA annotations. Hibernate implements the JPA specification:

    • http://java.net/projects/hyperjaxb/
    0 讨论(0)
提交回复
热议问题