I would like to bring this one up again. id-references are probably 80% of my indexedEmbedded code. Hibernate ORM optimizes for this as entities are not initialized when only the id is referenced. There is no reason Hibernate Search shouldn't. Especially the issue of cascading initialization (reindexation of root entities on save @IndexedEmbedded/@ContainedIn) which is a common performance issue with Hibernate Search might be positively affected by this as ids are immutable and often used as (potentially stale) cache references.
I can see @ManyToOne relations, relations that are available in the second level cache, etc being significantly improved. Also in a OneToMany(mappedBy) style relation, if a child entity references back to the owning entity with a @ContainedIn and is updated (as opposed to being created), no update to the index would be necessary since the immutable id will be guaranteed to be there already, thereby avoiding the cascading initialization issue.
|