Reputation: 133
Say I have a model A like this:
@Embeddable
class A {
@Field
private String name;
@Field
private Boolean editable;
@IndexedEmbedded
private B bObject;
}
where, B is, say
@Embeddable
class B {
@Field
private int intValue;
@Field
private boolean boolValue;
}
Now, I have a class C,
@Entity
class C {
//How to annotate this to enable search like setOfA.name="searchQuery", or setOfA.bObject.intValue=5
@ElementCollection
private Set<A> setOfA;
}
I see that I can create custom Bridge, but can't figure out what the Bridge should do, specially to enable search like setOfA.bObject.intValue = 5.
Any help is appreciated. Thanks.
Upvotes: 3
Views: 549
Reputation: 3017
Here is an working exemple:
@ElementCollection
@Field(name="listStringField")
@FieldBridge(impl=BuiltinIterableBridge.class)//ListStringBridge.class)
public List<String> getListString(){
return listString;
}
Upvotes: 3
Reputation: 18990
You need to add @OneToMany
or @ManyToMany
so it's a properly mapped association by terms of JPA. Then add @IndexedEmbedded
to enable full-text search through Hibernate Search.
Upvotes: 0
Reputation: 749
use @ContainedIn
over collection object like :
@ContainedIn
private Set<A> setOfA;
And use @IndexedEmbedded
over other side like :
@Embeddable
class A {
@Field
private String name;
@Field
private Boolean editable;
@IndexedEmbedded
private B bObject;
@OneToOne( cascade = { CascadeType.PERSIST, CascadeType.REMOVE } )
@IndexedEmbedded
private C cObject;
}
Upvotes: 1