Reputation: 1510
I have two tables (external, so I can not modify it). Tables has logical relationship (one has reference ID for other) only, without @OneTo* annotation.
Is it possible for Hibernate Search index this related objects?
The code sample:
@Entity
@Indexed
@Table(name = "E1")
public class E1 implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "ID")
private Long id;
@Column(name = "NAME", length = 32, nullable = false)
private String name;
@Column(name = "E2_FK", nullable = false)
@IndexedEmbedded // ????
private Long e2Id;
}
@Entity
@Table(name = "E2")
public class E2 implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "ID")
private Long id;
@Column(name = "DESCRIPTION", length = 4000, nullable = false)
@Field
private String description;
}
Upvotes: 0
Views: 98
Reputation: 19129
No, Hibernate Search can in this case not index the associated object. It does not know anything about it. Your mapping does not contain any pointer for Hibernate (Search) that e2Id is the primary key to another entity. @IndexedEmbedded is for associated entities.
Why don't you make this true associations. You can have them lazy loaded per default in case that is one of your concerns.
Upvotes: 1