Hyperjaxb3 naming strategy configuration

瘦欲@ 提交于 2019-12-23 04:29:21

问题


I'm trying to embed multiple instances of the same complextype into a single entity, which does not seem to work unless I define a new complextype for each instance. As far as I can make up until now, this is probably because of the default hyperjaxb3 naming strategy. Is there a way to change the default hyperjaxb3 naming strategy via annotations (similar to setting the id strategy, for example) rather than adding code to the plugin itself? Thanks, Frederik


回答1:


It would be much easier if you provide an example of what you're trying to do: schema, generated annotations and what you'd like to have generated instead.

Here's what I have in one of the test projects. Schema:

<xs:element name="a" type="aType"/>
<xs:complexType name="aType">
    <xs:sequence>
        <xs:element name="b0" type="bType" minOccurs="0"/>
        <xs:element name="b1" type="bType" minOccurs="0"/>
    </xs:sequence>
</xs:complexType>
<xs:complexType name="bType">
    <xs:annotation>
        <xs:appinfo>
            <hj:embeddable/>
        </xs:appinfo>
    </xs:annotation>
    <xs:sequence>
        <xs:element name="c" minOccurs="0">
            <xs:simpleType>
                <xs:restriction base="xs:string">
                    <xs:maxLength value="999"/>
                </xs:restriction>
            </xs:simpleType>
        </xs:element>
        <xs:element name="d" type="xs:int" minOccurs="0"/>
    </xs:sequence>
</xs:complexType>

Generates:

@Embedded
@AttributeOverrides({
    @AttributeOverride(name = "c", column = @Column(name = "B0_C", length = 999)),
    @AttributeOverride(name = "d", column = @Column(name = "B0_D", precision = 10, scale = 0))
})
public BType getB0() {
    return b0;
}
@Embedded
@AttributeOverrides({
    @AttributeOverride(name = "c", column = @Column(name = "B1_C", length = 999)),
    @AttributeOverride(name = "d", column = @Column(name = "B1_D", precision = 10, scale = 0))
})
public BType getB1() {
    return b1;
}

I don't see naming collisions.

UPDATE

Here's some links about customization of naming:

Check this guide:

http://confluence.highsource.org/display/HJ3/Customization+Guide

Here's a test project which demonstrates some of those features:

http://java.net/projects/hj3/sources/svn/show/trunk/ejb/tests/cu-one

You can also write and configure your own naming strategy:

http://java.net/projects/hj3/sources/svn/show/trunk/ejb/tests/custom-naming



来源:https://stackoverflow.com/questions/6481023/hyperjaxb3-naming-strategy-configuration

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!