使用Jaxb或HyperJaxb生成@Indexed注释

时间:2011-09-08 05:28:13

标签: annotations hibernate-search annotate hyperjaxb

我想在我的任务中实现基于lucene的hibernate搜索。为了生成域对象,我使用的是HyperJaxb3。

我希望在使用HyperJaxb创建域对象期间添加@Indexed注释。

我尝试谷歌搜索,但无法找到解决方案。

这方面的任何指针都会有很大的帮助。

1 个答案:

答案 0 :(得分:2)

Annotate plugin是正确的答案。请参阅this example

这就是它在架构中的表现:

  ....
  xmlns:hs="http://annox.dev.java.net/org.hibernate.search.annotations"
  ...

  <xsd:complexType name="USAddress">
    <xsd:sequence>
      <xsd:element name="name" type="xsd:string">
        <xsd:annotation>
          <xsd:appinfo>
            <annox:annotate>
              <hs:FieldBridge impl="org.jvnet.hyperjaxb3.ejb.tests.annox.Items">
                <params>
                  <hs:Parameter name="foo" value="bar"/>
                </params>
              </hs:FieldBridge>
            </annox:annotate>
          </xsd:appinfo>
        </xsd:annotation>
      </xsd:element>
      <xsd:element name="street" type="xsd:string"/>
      <xsd:element name="city" type="xsd:string"/>
      <xsd:element name="state" type="xsd:string"/>
      <xsd:element name="zip" type="xsd:decimal"/>
    </xsd:sequence>
    <xsd:attribute name="country" type="xsd:NMTOKEN" fixed="US"/>
  </xsd:complexType>

您还可以使用额外的绑定文件(请参阅example)。