2011-09-08 59 views
2

我想在我的任务中实现基于lucene的hibernate搜索。为了生成域对象,我使用了HyperJaxb3。使用Jaxb或HyperJaxb生成@Indexed注释

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

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

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

+0

我尝试使用annotate插件来添加像@Indexed这样的Hibernate Search注释,但无法实现。 –

+0

请发布错误消息,日志 - 说明问题的任何内容。它确实有效。 – lexicore

回答

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)。

+0

请在http://stackoverflow.com/questions/9799837/insert-custom-annotation-in-java-field-using-annotate-plugin-jaxb-upon-xsd看看我的相关问题。如果你能提供帮助,会很棒。 – Hari