Well, I resolved where problem was. Some of the entities where marked as insertable=false, updatable=false, thats why parent index was not updated.
I didn't show the whole entity. Below are corrections.
Code:
....
@Entity
class B{
@Column(name="PROJECT_ID", precision=10)
private Long aId;
@ContainedIn
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="PROJECT_ID", insertable=false, updatable=false)
private A a;
@IndexedEmbedded
@OneToMany(mappedBy="b", fetch=FetchType.LAZY, cascade=CascadeType.REMOVE)
private List<C> cs;
}
@Entity
class C{
@Column(name="TEST_REQUEST_ID", precision=10)
private Long bId;
@ContainedIn
@JoinColumn(name="TEST_REQUEST_ID"), insertable=false, updatable=false)
@ManyToOne(fetch=FetchType.LAZY)
private B b;
@IndexedEmbedded
@ManyToOne(fetch=FetchType.LAZY)
private D d;
}
...
Soonce hibernate add some C entity in this was neither B or A indexes where updated. I did it in order to reduce number of queries to DB when save new entity but in case of lucene such approach should be forbidden.
I hope my case helps somebody to avoid such situation.
P.S. Well, I've been too fast.
It works good only while inserting new C - it updates B and A. But when I update C, it updates only B, and A remains not updated, even when I removed insertable=false, updatable=false. Also when C is deleted, B is updated but A is not.
Seems like it updates only first level of parent.
Any ideas?