-->
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.  [ 4 posts ] 
Author Message
 Post subject: initial indexing issues
PostPosted: Thu Oct 04, 2012 11:09 am 
Newbie

Joined: Thu Oct 04, 2012 10:28 am
Posts: 2
Hi,

I am trying to implement hibernate-search in my application.
I included all the required libraries, added annotations to the entity class as described by the documentation.
Now, I need to do initial load into index files.

org.hibernate.search.FullTextSession fullTextSession = org.hibernate.search.Search.getFullTextSession(ThreadSession.get());
fullTextSession.createIndexer().startAndWait();

That’s where it fails with following error:

[2012-10-03T09:50:59.543-0400] [Hibernate Search: identifierloader-1] [ERROR] [IdentifierProducer] [95]: error during batch indexing:
org.hibernate.NonUniqueResultException: query did not return a unique result: 3
at org.hibernate.impl.AbstractQueryImpl.uniqueElement(AbstractQueryImpl.java:868) ~[hibernate3.jar:3.6.0.Final]
at org.hibernate.impl.CriteriaImpl.uniqueResult(CriteriaImpl.java:369) ~[hibernate3.jar:3.6.0.Final]
at org.hibernate.search.batchindexing.IdentifierProducer.loadAllIdentifiers(IdentifierProducer.java:124) ~[hibernate-search.jar:3.4.1.Final]
at org.hibernate.search.batchindexing.IdentifierProducer.inTransactionWrapper(IdentifierProducer.java:111) ~[hibernate-search.jar:3.4.1.Final]
at org.hibernate.search.batchindexing.IdentifierProducer.run(IdentifierProducer.java:92) ~[hibernate-search.jar:3.4.1.Final]
at org.hibernate.search.batchindexing.OptionallyWrapInJTATransaction.run(OptionallyWrapInJTATransaction.java:110) [hibernate-search.jar:3.4.1.Final]
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [na:1.6.0_31]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [na:1.6.0_31]
at java.lang.Thread.run(Thread.java:662) [na:1.6.0_31]

I know for sure that property marked with @DocumentId is unique because it is a database generated identifier.
So I have no idea why indexer complains about unique results. Logs do not show what exact query hibernate expects to return unique results.
Perhaps this error means something else?

My only suspicion is that method comparetTo() is overwritten in this entity class to compare on another field which is not unique in the database.
I could not find any documentation on either hibernate-search is using this function for indexing. Anybody knows?

Thanks for any help.


Top
 Profile  
 
 Post subject: Re: initial indexing issues
PostPosted: Fri Oct 05, 2012 5:40 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Hi,

compareTo() is unrelated, we never invoke that.

The @DocumentId annotated field isn't relevant either in this case (although you're correct in saying that it should be unique).

The relevant field in this case is the primary identifier of the entity on the database: @Id

This is the relevant code, could you try executing this and see if it runs fine on all your entities?

Code:
Criteria criteria = session
    .createCriteria( indexedType )
    .setProjection( Projections.id() )
    .setCacheable( false )
    .setFetchSize( idFetchSize );
      
    ScrollableResults results = criteria.scroll( ScrollMode.FORWARD_ONLY );

while ( results.next() ) {
            Serializable id = (Serializable) results.get( 0 );
}


It would be a good idea to enable logging of SQL statements too.
http://docs.jboss.org/hibernate/core/4.1/manual/en-US/html_single/#configuration-logging

Finally, these versions are quote old; any chance you could try latest stable releases?

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


Top
 Profile  
 
 Post subject: Re: initial indexing issues
PostPosted: Fri Oct 05, 2012 10:49 am 
Newbie

Joined: Thu Oct 04, 2012 10:28 am
Posts: 2
Thanks Sanne for quick reply.

Your point about @Id annotation brings up a good point I did not mention before.
My hibernate configuration is xml-based, old way, not annotation-based.
Sounds like it might be the issue.

If so, I have to look into converting my project to annotation-based configuration.

Thanks again for your help.

Anatolii.


Top
 Profile  
 
 Post subject: Re: initial indexing issues
PostPosted: Fri Oct 05, 2012 10:55 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Hi Anatolii,

Quote:
Your point about @Id annotation brings up a good point I did not mention before.
My hibernate configuration is xml-based, old way, not annotation-based.
Sounds like it might be the issue.

If so, I have to look into converting my project to annotation-based configuration.


Well annotations should bring you many benefits, so I won't stop you but I don't expect that to be the issue. Let me know anyway, I might be wrong.

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


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