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?