-->
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.  [ 3 posts ] 
Author Message
 Post subject: Indexing doesn't end...
PostPosted: Wed Dec 30, 2009 6:46 pm 
Newbie

Joined: Wed Dec 30, 2009 6:34 pm
Posts: 2
Good night, everyone.

I have just one class mapped by hibernate ( using annotations ) and this class is also annotated by hibernate search annotations.

It is an hibernate search test.

Code:
@Indexed(index="Convidado")
@Entity
public class Convidado {

    @Id
    @GeneratedValue
    @DocumentId
    private Long id;

    @Field(index=Index.TOKENIZED, store=Store.YES)
    private String nome;

    @Temporal(TemporalType.DATE)
    private Date dataNascimento; // data de nascimento para ver possiveis clientes

    @Temporal(TemporalType.TIMESTAMP)
    private Date dataCadastro;

    // getters and setters
}


I have this code to index all data

Code:
        FullTextSession fullTextSession = getFullTextSession();
        Transaction tx = fullTextSession.beginTransaction();
        tx.begin();
        fullTextSession.setCacheMode(CacheMode.IGNORE);
        fullTextSession.setFlushMode(FlushMode.MANUAL);

        Paginacao pag = new Paginacao(1, 5000, 0, 0);
        List<Convidado> convidados = getConvidadoDao().getLista(new Convidado(), pag);
        for(Convidado e : convidados){
            System.out.println("Indexing convidado "+e.getNome());
            fullTextSession.index(e);
        }

        System.out.println("Finished");
        if(tx.isActive()){
            System.out.println("Transaction is active, it will commit now");
            tx.commit();
            System.out.println("Comitted");
        }


I have just a few records on database to be indexed. ( about 8 )

i have the following output

Indexing convidado Helio Ricardo
Indexing convidado Flávia Trindade
Indexing convidado Neyde Vieira
Indexing convidado Walter Gomes
Indexing convidado Rita de Cássia
Indexing convidado Alex Dias
Finished
Transaction is active, it will commit now
Comitted

It runs until the last line of code but the program keeps running... To finish it, i have to stop manually.

It does index all data but it doesn't finish running. Yesterday i left running for almost an hour and it didn't stop.

Anybody can help me?


Top
 Profile  
 
 Post subject: Re: Indexing doesn't end...
PostPosted: Wed Dec 30, 2009 6:55 pm 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Hi,
I guess you forgot to close the SessionFactory:
Code:
getFullTextSession().getSessionFactory().close();


BTW for a trivial test this is fine, but keep in mind your indexing routing won't work well on large datasets as it's keeping them all in memory. See the reference docs for a better version.

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject: Re: Indexing doesn't end...
PostPosted: Wed Dec 30, 2009 7:01 pm 
Newbie

Joined: Wed Dec 30, 2009 6:34 pm
Posts: 2
Really really thx!

it worked!

Thank you very much!

God bless you


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.