开发者

Hyperjaxb3 naming strategy configuration

开发者 https://www.devze.com 2023-03-15 05:14 出处:网络
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

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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号