-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 posts ] 
Author Message
 Post subject: Lucene index gets deleted on Hibernate configuration
PostPosted: Sun Dec 18, 2005 11:44 am 
Newbie

Joined: Sun Dec 18, 2005 11:18 am
Posts: 2
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;
   }
}


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 19, 2005 6:56 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
be sure to use the latest HA 3.1beta7

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 19, 2005 9:01 am 
Newbie

Joined: Sun Dec 18, 2005 11:18 am
Posts: 2
Thanks, that did the trick.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 08, 2006 2:21 am 
Beginner
Beginner

Joined: Mon Feb 07, 2005 10:40 pm
Posts: 22
how about the objects in the database that are not indexed?, what will be the way to recreate the index without having to run fake updates in every single persistent object?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 08, 2006 2:44 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Good question, we might need some IndexGenerator task to init the lucene index.
Are you interested in contributing?

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 08, 2006 6:31 pm 
Beginner
Beginner

Joined: Mon Feb 07, 2005 10:40 pm
Posts: 22
I have no experience whatsoever with ant but if you have any suggestion in how to implement this, yes I would like to contribute.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 09, 2006 9:48 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
It probably can be done the way SchemaExport is done currently

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 09, 2006 9:50 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
note that the build task is build on top of schema export so no need for ant knowledge to begin :-)

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.