I am using hibernate-search 3.0.1.GA.
I am trying to create an index with entities that inherit off a base entity;
Here is the main entity I want to store the id in the index. It has many text items. The text item has two child classes one child has a varchar the other has a clob. I want to index the text for both of those child entities in the same index. I.E. when searching for text I want my search to return a docId if the text exists in either if my children classes/tables.
Code:
@Entity
@Indexed(index = "text")
@Table(name = "DOC")
public class Doc implements java.io.Serializable {
.
private Set<TextItem> textItems = new HashSet<TextItem>(0);
.
.
@Id
@DocumentId
@Column(name = "DOC_ID", unique = true, nullable = false, scale = 0)
@GeneratedValue( strategy=GenerationType.SEQUENCE, generator="GS_DOC_GEN" )
@SequenceGenerator( name="GS_DOC_GEN", sequenceName="GS_DOC", allocationSize=1 )
public long getDocId() {
return this.docId;
}
.
.
@IndexedEmbedded
@OneToMany(fetch = FetchType.LAZY, mappedBy = "doc", cascade = CascadeType.ALL)
public Set<TextItem> getTextItems() {
return this.textItems;
.
.
}
TextItem entity (this is the parent class) This class does not have any search annotations, the children classes have them
Code:
Entity
@Table(name = "TEXTITEM")
@Inheritance(strategy=InheritanceType.JOINED)
public class TextItem implements java.io.Serializable {
.
.
.
.
Here is one of the children (both look the same except for type of text field)
Code:
@Entity
@Table(name="TEXTITEM_CHR_VALUE")
public class TextItemCharValue extends TextItem {
.
.
@Column(name="VALUE", nullable=false)
@Field(index=Index.TOKENIZED)
public String getValue() {
return this.value;
}
.
.
So I want to index the value field on my child table so I use the @Field. I am not sure if I need anything on the parent class (TextItem) as far as annotations, and I have the EmbeddedIndex annotation on the TextItems in the Doc entity.
I am not getting a field for value for this situation. If I have a @Field in the parent class a field gets created just fine but it seems like the @Field annotations are ignored in the children classes. How do I index off of DocID when the Doc entity contains a set of parent entities that do not have anything to store (the children have the data)?
Thanks in advance!