[hibernate-issues] [Hibernate-JIRA] Resolved: (HSEARCH-389) Filtering using criteria API is unreliable

Emmanuel Bernard (JIRA) noreply at atlassian.com
Thu Apr 8 10:33:43 EDT 2010


     [ http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-389?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Emmanuel Bernard resolved HSEARCH-389.
--------------------------------------

    Resolution: Incomplete

No user feedback

> 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.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list