Hibernate-search OneToMany infinite indexing -
all help/comments appreciated
i've got @onetomany relationship. tvenue , tvenueitem want able search on various fields on venue i've marked @indexed. setup so:
@indexed @entity public class tvenue implements java.io.serializable { private set<tvenueitem> tvenueitems = new hashset<tvenueitem>(0); ....... @onetomany(cascade=cascadetype.all, fetch=fetchtype.lazy, mappedby="tvenue") public set<tvenueitem> gettvenueitems() { return this.tvenueitems; } ...........
and
@entity public class tvenueitem implements java.io.serializable { private string name; private tvenue tvenue; ........... @manytoone(fetch=fetchtype.lazy) @joincolumn(name="venue_id", nullable=false) public tvenue gettvenue() { return this.tvenue; } @field @column(name="_name", nullable=false, length=100) public string getname() { return this.name; } .......
no problems far.
now, independently want search on fields of tvenueitem mark @indexed also.
the problem: add @indexed tvenueitem (manual) indexing hangs forever presumably because or infinite recursion.
anyone know how avoid problem? understand tvenue owning entity , operations on tvenueitem can done tvenue. however, i'd able search on tvenueitem independently regardless.
thanks
j
i've found solution. try use this:
@indexed @entity public class tvenue implements java.io.serializable { private set<tvenueitem> tvenueitems = new hashset<tvenueitem>(0); ....... @onetomany(cascade=cascadetype.all, fetch=fetchtype.lazy, mappedby="tvenue") @indexedembedded(prefix = "tvenue.item") public set<tvenueitem> gettvenueitems() { return this.tvenueitems; } ...........
and:
@entity public class tvenueitem implements java.io.serializable { private string name; private tvenue tvenue; ........... @manytoone(fetch=fetchtype.lazy) @joincolumn(name="venue_id", nullable=false) @containedin public tvenue gettvenue() { return this.tvenue; } @field @column(name="_name", nullable=false, length=100) public string getname() { return this.name; } .......
for more information look here
Comments
Post a Comment