簡體   English   中英

Hyperjaxb忽略binding.xjb中的自定義

[英]Hyperjaxb ignoring customization in binding.xjb

我正在使用hyperjaxb3,它成功解決了我的大多數問題。

但是,我整個上午都在解決我無法解決的問題。 最有可能是我完全忽略的那些愚蠢而愚蠢的事情之一,但是我找不到它。

問題是,在bindings.xjb內部,我試圖更改我的實體之一的生成表名,但是無論我嘗試什么,我設置的值都將被完全忽略。

這些是相關文件的內容:

XSD文件(只是一個片段)

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://.../es/xbrl/eu/model/concept-statement" xmlns:fws="http://.../es/xbrl/eu/model/concept-statement">
    <xs:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="http://www.w3.org/2001/xml.xsd"/>

    <xs:element name="structure">
        <xs:complexType>
            <xs:sequence>
                <xs:element ref="fws:module"/>
            </xs:sequence>
        </xs:complexType>
     </xs:element>

bindings.xjb

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<jaxb:bindings
    version="2.1"
    xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:hj="http://hyperjaxb3.jvnet.org/ejb/schemas/customizations"
    xmlns:orm="http://java.sun.com/xml/ns/persistence/orm"
    jaxb:extensionBindingPrefixes="hj orm">

    <jaxb:bindings schemaLocation="concept-statement.xsd" node="/xs:schema">
        <jaxb:schemaBindings>
            <jaxb:package name="es.company.cirbe.cubo.hechos.modelo"/>
        </jaxb:schemaBindings>
        <jaxb:globalBindings localScoping="toplevel">
            <jaxb:serializable/>
        </jaxb:globalBindings>
        <jaxb:bindings node="xs:element[@name='structure']">
            <hj:entity>
                <orm:table name="FACTS_STRUCTURE"/>
            </hj:entity>
        </jaxb:bindings>
    </jaxb:bindings>
</jaxb:bindings>

pom.xml(僅依賴關系和構建部分)

<dependencies>
    <dependency>
        <groupId>org.hibernate.javax.persistence</groupId>
        <artifactId>hibernate-jpa-2.1-api</artifactId>
        <version>1.0.0.Final</version>
    </dependency>
    <dependency>
        <groupId>org.glassfish.jaxb</groupId>
        <artifactId>jaxb-runtime</artifactId>
        <version>2.2.11</version>
    </dependency>
    <dependency>
        <groupId>org.jvnet.hyperjaxb3</groupId>
        <artifactId>hyperjaxb3-ejb-runtime</artifactId>
        <version>0.6.0</version>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.jvnet.hyperjaxb3</groupId>
            <artifactId>maven-hyperjaxb3-plugin</artifactId>
            <executions>
                <execution>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <debug>false</debug>
                <extension>true</extension>
                <variant>ejb</variant>
                <generateDirectory>src/main/java</generateDirectory>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <configuration>
                <excludes>
                    <exclude>**/persistence.xml</exclude>
                </excludes>
            </configuration>
        </plugin>
    </plugins>
</build>

生成的java文件

@XmlRootElement(name = "structure")
@Entity(name = "Structure")
@Table(name = "STRUCTURE_")
@Inheritance(strategy = InheritanceType.JOINED)
public class Structure
    implements Serializable, Equals, HashCode
{
}

我絕對確定正在讀取綁定文件:我已經檢查了兩個maven日志,並且,如果我對xpath表達式設置了一些奇怪的值,則會得到與它們相關的運行時異常。

此外,它不僅忽略了表名的自定義。 我嘗試過更改實體名稱,架構,為簡單屬性設置不同的列長...在所有這些測試中,輸出始終與我上面復制的相同。

而且我還檢查了現有示例,但看不到我在做什么錯。

問候

好的,發現了問題,這與我的XSD文件的結構有關。

只是使用

xs:element[@name='structure']

在我的綁定文件上還不夠。 看起來,表映射自定義僅在與complexTypes關聯時才起作用,因此我將其更改為

xs:element[@name='structure']/xs:complexType

一切都按預期工作:)

希望這對以后的人有所幫助。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM