2011-09-08 110 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