Hibernate version: 3.1 (also hibbernate annotations 3.1)
I'm experimenting with Hibernate annotations connected to Lucene...
At first it seems to works great. I succesfully save everything in the database, and then do Lucene query, and I get the results as expected.
But something weird happens. Next time, when I start my test program, and the following Hibernate initialization code gets exectuted, the Lucene index gets deleted.
Code:
static {
Configuration config = new AnnotationConfiguration();
config.configure();
new SchemaUpdate(config).execute(true, true);
sessionFactory = config.buildSessionFactory();
session = sessionFactory.openSession();
}
I tried removing the SchemaUpdate line, but still the same happens.
What am I doing wrong ?
Further Details:As stated in the documentation, I have added those lines to the hibernate configuration:
Code:
<event type="post-commit-update">
<listener class="org.hibernate.lucene.event.LuceneEventListener" />
</event>
<event type="post-commit-insert">
<listener class="org.hibernate.lucene.event.LuceneEventListener" />
</event>
<event type="post-commit-delete">
<listener class="org.hibernate.lucene.event.LuceneEventListener" />
</event>
This is the annotated POJO:
Code:
@Entity
@Indexed(index="c:/index")
@Table(name="CLIENT")
public class Client {
private long id;
private String comment;
...
...
@Id(generate=GeneratorType.IDENTITY)
@Keyword(id=true)
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
@Text(name="comment")
public String getComment() {
return comment;
}
public void setComment(String comment) {
this.comment=comment;
}
}