[hibernate-dev] [Search] Projections of collection of elements with embeddable

Davide D'Alto davide at hibernate.org
Wed May 20 06:58:58 EDT 2015


Hi,

while working on OGM-781 I noticed that there is a problem with Hibernate
Search when trying to get the projection of a property that represents a
collection of elements..

EntityInfo#getProjections()[0] will always return the first value of the
association.

For example, if I index the following entity:

    @Indexed
    public static class ExampleEntity {

        @Field(store = Store.YES)
        Integer someInteger;

        ...

        @Field(store = Store.YES)
        @IndexedEmbedded
        List<Integer> someCollection;
    }

and than add a projection on  "someCollection"

EntityInfo.getProjection()[0] will only return the first result of the
collection instead of returning a List<Integer>.

This seems a bug to me.
I've already created a local branch that should fix the behaviour in this
case.

It also makes me wonder, what should we do with a list of embeddables?

For example:

@Field(store = Store.YES)
@IndexedEmbedded
List<ExampleEntity> nestedExamples

In this case,  would it make sense to project "someCollection.someInteger"?
And what would be the expected result calling EntityInfo.getProjection()[0]?

Cheers,
Davide


More information about the hibernate-dev mailing list