fedotxxl wrote:
The problem is: the following code doesn't make correct index
Code:
child.setParent(parent)
. To get correct index I have to make
Code:
parent.addChild(child)
. I think it is not good if I only want correct Lucene index
I don't understand why it is bad to have a bi-directional relation. Is it not a good thing that you can get from parents to children and vice versa. If you use lazy loading properly it is just a win at no almost no cost. And sure, if you have a bidirectional relation you have to set both ends.
I think I solved my problem by using Interceptors and custom FieldBridges. At save/delete time of child I execute
Code:
fullTextSession.index(child.getParent())
. Parent has property "luceneChilds" which returns "this". FieldBridge of property "luceneChilds" collects all childs and creates Lucene fields =)[/quote]
That's seems to be an awful lot of work and customization for something which could be very easy. A custom field bridge could of course solve your problem. However, I am wondering what
luceneChilds really is? In the end you need to navigate from parent to child. Also, how do you collect the children in the bridge? If you are running another query what do you gain really?
--Hardy