使用 hyperjaxb3 的 Hibernate 索引

Hibernate index using hyperjaxb3

我正在尝试使用 hyperjaxb 向简单属性添加索引,在我的 .xjb 文件中使用以下片段:

<jxb:bindings node="./xsd:attribute[@name='serviceCode']">
    <annox:annotate target="getter">
        <annox:annotate annox:class="org.hibernate.annotations.Index" name="product_index_serviceCode" columnNames="SERVICE_CODE"/>
    </annox:annotate>
    <hj:basic>
        <orm:column length="120"/>
    </hj:basic>
</jxb:bindings>

我收到“解析注释时出错。”我在 .xjb 文件中有注释的那一行出错。如果我删除注释,那么它工作正常,但显然,我没有得到索引。我还尝试将注释移动到 hj:basic 元素内. 在那种情况下,我没有收到错误,但也没有生成索引。

如@lexicore 所示,您需要将 Hibernate 注释 JAR 作为插件放在 JAXB 注释插件旁边。