簡體   English   中英

@ContainedIn實體保存到數據庫后不會自動建立索引

[英]A @ContainedIn entity does not get indexed automatically, when it gets saved to the DB

每當使用新的Photo實體時,我都在使用Hibernate Search自動更新Lucene索引。保存或編輯照片數據時,它很快會自動在索引中獲取。 但是,當添加注釋時,它永遠不會進入。這正是@IndexedEmbedded/@ContainedIn應該做什么,對嗎?

我的代碼大致如下:

@Indexed(index="/indexes/photo.index")
@Entity
public class Photo {

    @IndexedEmbedded
    @OneToMany(mappedBy="photo", fetch = FetchType.LAZY)
    public List<Comment> comments;

}

@Indexed(index="indexes/comment.index")
@Entity
public class Comment {

    @ContainedIn
    @ManyToOne
    public Photo photo;

    @Field
    public String text;
}

我正在使用以下lib版本:

hibernate-search-3.4.0.Final
lucene-core-3.6.0
lucene-analyzers-3.1.0

注意:對於那些立即跳起來的人,說我弄亂了這兩個注釋的順序,我會說我也嘗試了另一種方法。 不起作用

版本3.4.0.Final是第一個包含優化檢查的版本,在以后的版本中更加穩定。 您可以嘗試設置休眠配置屬性嗎

hibernate.search.enable_dirty_check=false

確保此類優化不會影響您。

另外,請使用此發行版設計的Lucene版本,否則您可能會遇到任何麻煩:

lucene-core-3.1.0
lucene-analyzers-3.1.0

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM