[
http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-389?pag...
]
Emmanuel Bernard commented on HSEARCH-389:
------------------------------------------
As far as I can tell, the algorithm is not flawed but I am not fully understanding your
use case. Particularly on step 2, can you define filtering. a code snippet or better a
unit test would help to clarify that.
It seems to you that you are doing something that we explicitly do not support, which is
using the Criteria API to further restrict your matching results instead of using the full
text query or the Hibernate Search filter algorithm. FTR we do not support that because it
would lead to inconsistent pagination and result size.
Filtering using criteria API is unreliable
------------------------------------------
Key: HSEARCH-389
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-389
Project: Hibernate Search
Issue Type: Bug
Components: query
Affects Versions: 3.1.0.GA, 3.1.1.GA
Environment: Hibernate 3.3.2.GA, Hibernate Entity Manager 3.4.0.GA, Oracle 9.2
Reporter: Dirk Mahler
Assignee: Emmanuel Bernard
Within one EntityManager session the following use case leads to wrong results if using
Hibernate Search in combination with the Criteria API:
1. Execute a simple query which returns Entity A and B as results
2. Doing a full text query which will find A and B but restricts the results to A by
doing a further filtering for an attribute which is only satisfied by A using the criteria
API.
Hibernate Search returns both A and B. After looking at the source code the reason seems
to be the follwoing:
- the full text search returns a list of entities
- the Criteria query is simply used to initialize the entities within the
EntityManager's session, the result set/list itself is ignored, see
ObjectLoaderHelper#initializeObjects(EntityInfo[] entityInfos, Criteria criteria,
Class<?> entityType, SearchFactoryImplementor searchFactoryImplementor):
...
criteria.add( disjunction );
criteria.list(); //load all objects <-- ???
}
- the result is now determined by checking wether the entities from the full text search
are initialized using Hibernate.isInitalized(), see QueryLoader#load(EntityInfo...
entityInfos and returnAlreadyLoadedObjectsInCorrectOrder(EntityInfo[] entityInfos, Session
session))
This approach is highly fragile because it relies on side effects and should be discarded
in favor of using the result of the criteria query which already represents the expected
result. Is there any good reason to ignore it?
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira