-->
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: Query problem
PostPosted: Thu Apr 28, 2011 10:28 am 
Newbie

Joined: Thu Apr 28, 2011 10:16 am
Posts: 3
Hi,

I have this code:

List<ProducingEntity> result = new ArrayList<ProducingEntity>();
FullTextEntityManager fullTextEntityManager = org.hibernate.search.jpa.Search.getFullTextEntityManager(getEntityManager());
SearchFactory searchFactory = fullTextEntityManager.getSearchFactory();
QueryBuilder producingEntityQB = searchFactory.buildQueryBuilder().forEntity(ProducingEntity.class).get();
CQLToQueryTranslator ctq = new CQLToQueryTranslator(getDefaultSearchFields());
try {
Query q = ctq.createQuery(producingEntityQB, query);
FullTextQuery fullTextQuery = fullTextEntityManager.createFullTextQuery(q, ProducingEntity.class);
result = fullTextQuery.getResultList();
return result;
} catch (Exception e) {
logger.error("ERROR:" + e.getMessage(), e);
}

The CQLToQueryTranslator translates a CQL query to a Lucene Query.
The problem is:
When the query returns 0 matches, everything works fine.
When the query must return something, it takes almost 30s to initialize the result variable (result = fullTextQuery.getResultList() ).
If I try to get the number of matches (fullTextQuery.getResultSize() ), it gives methe correct result in less than a second...
Note : The query is a simple query ( fieldName : value). And I have only 1 record in the database (just for testing)...

Any idea?

Thanks.


Top
 Profile  
 
 Post subject: Re: Query problem
PostPosted: Fri May 06, 2011 4:33 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
We need ways more context to give an answer:
  • What does CQLToQueryTranslator really do
  • How does the query look like?
  • How does your domain model look like? Are you having a circular dependency in your object graph? Are you maybe using
    @IndexedEmbedded w/o specifying the depth paramter?

--Hardy


Top
 Profile  
 
 Post subject: Re: Query problem
PostPosted: Fri May 06, 2011 4:58 am 
Newbie

Joined: Thu Apr 28, 2011 10:16 am
Posts: 3
I've solved my problem. I had a embedded lists of objects and i use EAGER fetching... It works fine with hibernate-core, but when used with hibernate-search it crashes... I changed to LAZY fetching, and with little changes it works great. Thanks.


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.