[hibernate-dev] About mapping of @IndexedEmbedded and @DocumentId

Sanne Grinovero sanne at hibernate.org
Tue Mar 15 11:43:59 EDT 2011


2011/3/15 Emmanuel Bernard <emmanuel at hibernate.org>:
> Are you talking about JPA entities (with @Entity and @Id or mere mortal POJOs?

I got a bit confused for the reasons of your question, so I made some tests.
The index state reported in the previous email was about annotation
mapped entities, I repeated
the same test on "Infinispan Query POJOs", so the root element is
marked only with

"@ProvidedId @Indexed"

And the contained-in objects have no class level annotations.

As the contained-in elements in the collection don't get assigned a
provided-id, the ID FieldBridge is not adding
it to the index as it skips empty values.
If I add a javax.persistence.Id annotated field (even while I'm not
making it an entity), the ID property gets indexed.

In the case in which nothing is added to the index as id for the
embedded value, I can still query fine so it looks like
this shouldn't be indexed.
Also, it would improve a bit on HSEARCH-183 and HSEARCH-659, at least
the "id" field wouldn't be overwritten when people use an empty prefix
for @IndexedEmbedded (which is quite dangerous, as it will result in
apparently randomly selected values to be returned).

I guess we should prevent the indexing of ids in secondary elements?

Sanne

>
> On 14 mars 2011, at 21:26, Sanne Grinovero wrote:
>
>> Hello,
>> while debugging I just noticed that having a two entities scenario like
>>
>> @Indexed class Book {
>> Long id;
>> @IndexedEmbedded Nation bublishedFirstIn;
>> }
>> Nation { //NOT indexed
>> Long id;
>> @Field name
>> }
>>
>> the index for Book will contain these fields:
>>
>> _hibernate_class  ------------- NOT_ANALYZED_NO_NORMS, STORED
>> id  ----------------------------------- NOT_ANALYZED_NO_NORMS, STORED
>> bublishedFirstIn.id ------------ NOT_ANALYZED, STORED
>> bublishedFirstIn.name ------ ok (don't care)
>>
>> So, doubts:
>> 1) I guess at minimum "bublishedFirstIn.id" should use
>> NOT_ANALYZED_NO_NORMS as well, saving some precious memory and index
>> space (see HSEARCH-473)
>>
>> 2) Why is "bublishedFirstIn.id" at all indexed? I can't think of a use
>> case, likely missing something.
>>
>> 3) (Extreme) why is "id" indexed ? Are we ever supposed to run a full
>> text query on the id fields? I think we should have an option about
>> this, and in future default to Store only.
>>
>> Cheers,
>> Sanne
>> _______________________________________________
>> hibernate-dev mailing list
>> hibernate-dev at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/hibernate-dev
>
>




More information about the hibernate-dev mailing list