|
Today, people need to use create an association to go from an embedded entity B to the containing entity A and annotate it with @ContainedIn. This is necessary for us to know which instance of A contains the instance of B. This is sometimes undesirable as the association is not necessary for the application. This is particularly true of ToMany associations.
An alternative approach would be to let the user express a query instead of materializing an association.
@Entity
@ContainedIn("from A a where a.b.id in (:listOfIds)")
class B {
...
}
@Entity
@Indexed
class A {
@IndexedEmbedded
B b;
}
I think that's a not too complicated feature that can be done by a community member.
We might want to abstract away from a query string and use an interface / implementation so that Hibernate Search working in non ORM environment can still benefit from this approach. I haven't thought much about this abstraction.
|