[hibernate-dev] [HSEARCH-566] Indexing null values for an @ElementCollection

Emmanuel Bernard emmanuel at hibernate.org
Mon Aug 1 03:41:05 EDT 2011


On 31 juil. 2011, at 21:44, Sanne Grinovero wrote:

> @ElementCollection
> @Field(indexNullAsl="nullToken")
> String[] tags

Hum is it really the way we are going? ie @Field would be used by the elements of the collection if it's a collection?

I'm not a big fan for a couple of reasons:

- it breaks backward compatibility
- I cannot write a custom collection bridge

We're back to the same problem over and over but to me the best mapping in Java 8 will be:

@ElementCollection
Collection<@Field(bridge=StringBridge.class) String> tags

But until then we need to find alternatives. I can see two alternatives

1. use a custom @ElementField annotation

This annotation will represent the element in a collection.
I like this idea as it forward compatible with Java 8's approach

2. Let @Field be used for elements of a collection and create a @CollectionField to index the collection

Subsidiary questions:

- is there other annotation that need to be converted to the @Element* pattern?
- what about maps and specifically keys in maps?





More information about the hibernate-dev mailing list