Hallo, I'm using Hibernate Search in combination with the
Programmatic API for dynamic indexing. Is there any possibility to index an entity with an composite primary key annotated with
@EmbeddedId. Using H.Search without the Programmatic API i choose a TwoWayFieldBridge but how can I use it with the Programmatic API?
In my case I am trying to implement a programmatic mapping for an entity. The entity has an an composite primary key annotated with @EmbeddedId.
Code:
...
@Entity(name = "a")
@Table(name = "a")
public class A implements java.io.Serializable {
...
@EmbeddedId
@AttributeOverrides( {
@AttributeOverride(name = "name_1", column = @Column(name = "name_1", nullable = false, length = 64)),
@AttributeOverride(name = "name_2", column = @Column(name = "name_2", nullable = false, length = 16)) })
public AId getId() {
return this.id;
...
}
Code for ABridge.class is not shown but still exists ..
I try a code like this, but the code does not work:
Code:
mapping.entity(A.class).indexed().indexName("a")
.property("id", ElementType.METHOD).documentId().field().bridge(ABridge.class)
Exception occurred during event dispatching:
org.hibernate.HibernateException:
could not init listeners...
Caused by: org.hibernate.search.SearchException:
Unable to guess FieldBridge for id...
I need an advise to solve my problem. Thanks