This question is re: HSEARCH-566: Support mapping of @javax.persistence.ElementCollection
http://opensource.atlassian.com/project ... SEARCH-566The issue is marked as targetted for 3.3, but is still in status Unresolved and the comments sound like the feature is not in for 3.3..
I've looked at the pdf docs for 3.3RC1 but see no mention of ElementCollection. Before I spend time building a test project and experimenting, can I ask if this feature is supported?
I guess it would mean we could define a collection in java code, and have each member of the collection appear in the index, i.e.:
Code:
@ElementCollection(fetch=FetchType.LAZY)
private Map<String, String> attributes;
Also, will we be able to map a collection of diverse types like:
Code:
@ElementCollection(fetch=FetchType.LAZY)
private Map<String, Object> attributes;
where each value of attributes is a different type? (Integer, Date, String etc.) or is the best way to model attributes of diverse types to express them as distinct fields with their own @Field annotation and mapping (bridge etc.)?
Some background to my question: I have a basic Item class which is mapped to a lucene index using HSearch 3.2. A customer wants to be able to store a custom type of item (motorbikes), which will need custom fields being mapped and searchable (cc, year, registration number). A perfect solution would be to be able to store a Map<String, Object> of e.g. "cc" => Integer(1000), "year"=>Integer(2002), "regno"=>String("ABC123") .. but I imagine this will be impossible to map to a Lucene index via a simple @ElementCollection annotation, right?
I guess the 'best' way handle these fields is to derive a class from my Item class and add these fields as a specific attributes annotated with @Field.
A test has shown me that simply deriving a Bike class from Item, and adding these fields, makes the new fields show up in the database 'item' table, and on the Item lucene index, so this solution would seem to work, but I'd rather not express the fields as distinct attributes if I can avoid it, because my data model becomes hardcoded in my java source, rather than being left as a very flexible Map<String, Object>.
Comments on any of these points would be welcome :)
Thanks
Nick