Hibernate version:
3.2.4
Setting:
JbossAS 4.2.2, JPA + EJB3
Name and version of the database you are using:
mysql 5.0.51b
Hello everybody, my Problem is the following:
I am trying to use hibernate search to index an entity class which inherits fields from a class annotated with @MappedSuperclass. After generating the index, the indexfiles contain no information at all. The inheritance structure looks like this:
Code:
@mappedSuperclass
classA{
@Field(store=Store.YES,index=Index.TOKENIZED)
field 1
}
@Entity
@Indexed
classB extends classA{
}
The mapped Entity classes:The mappedSuperclass:
Code:
@MappedSuperclass
public class DBDocumentDataBase extends DBHistorizable implements Serializable {
@Field(store=Store.YES,index=Index.TOKENIZED)
private String infoXml = "";
@Field(store=Store.YES,index=Index.TOKENIZED)
private String title = "";
private ContentType contentType = ContentType.UNKNOWN;
public ContentType getContentType() {
return contentType;
}
public void setContentType(ContentType contentType) {
this.contentType = contentType;
}
public String getInfoXml() {
return infoXml;
}
public void setInfoXml(String infoXml) {
this.infoXml = infoXml;
}
public void setTitle(String title) {
this.title = title;
}
}
Code:
@Entity
@Indexed
@Table(name = "DD_DOCUMENT_DATA")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "DD_DISCRIMINATOR", discriminatorType = DiscriminatorType.STRING)
@DiscriminatorValue("document")
@AttributeOverrides( {
@AttributeOverride(name = "infoXml", column = @Column(name = "DD_INFO_XML", nullable = false,length=1700000000)),
@AttributeOverride(name = "title", column = @Column(name = "DD_TITLE", nullable = false)),
@AttributeOverride(name = "contentType", column = @Column(name = "DD_CONTENT_TYPE", nullable = false)) })
public class DBDocumentData extends DBDocumentDataBase {
private static final long serialVersionUID = 4480775079285637738L;
@Id
@DocumentId
@GeneratedValue
@Column(name = "DD_ID", unique = true)
private int id;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
}
code to create the indexes:
Code:
public void createIndex(){
FullTextEntityManager fullTextEntityManager = Search.createFullTextEntityManager(em);
List<DBDocumentData> docs = em.createQuery("select doc from DBDocumentData as doc").getResultList();
for (DBDocumentData doc : docs) {
fullTextEntityManager.index(doc);
}
}
The persistence.xml
Code:
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
version="1.0">
<persistence-unit name="sumodoc_persistence">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:/mySQLDS</jta-data-source>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
<property name="hibernate.hbm2ddl.auto" value="update"/>
<property name="jboss.entity.manager.jndi.name" value="java:/sumodoc_entitymanager"/>
<property name="jboss.entity.manager.factory.jndi.name" value="java:/sumodoc_entitymanager_factory"/>
<property name="hibernate.search.default.directory_provider" value= "org.hibernate.search.store.FSDirectoryProvider"/>
<property name="hibernate.search.default.indexBase" value="~/sqms/indexes"/>
<property name="hibernate.ejb.event.post-insert"
value="org.hibernate.search.event.FullTextIndexEventListener"/>
<property name="hibernate.ejb.event.post-update"
value="org.hibernate.search.event.FullTextIndexEventListener"/>
<property name="hibernate.ejb.event.post-delete"
value="org.hibernate.search.event.FullTextIndexEventListener"/>
</properties>
</persistence-unit>
</persistence>
The fields infoXML and title from the superclass are not null, when I create the index.
My question is: is it generally possible to use hibernate search in such a setting or does Hibernate search doesn't support inheritance?
Any hints would be much appreciated.