[Hibernate-JIRA] Created: (HSEARCH-305) Hibernate search doesn't work with criteria when it is not initialized laziily
by prabhu lal (JIRA)
Hibernate search doesn't work with criteria when it is not initialized laziily
------------------------------------------------------------------------------
Key: HSEARCH-305
URL: http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-305
Project: Hibernate Search
Issue Type: Bug
Components: query
Affects Versions: 3.0.1.GA
Environment: MYSQL,HIBERNATE 3.0 , Flex with dpHibernate
Reporter: prabhu lal
Attachments: QueryLoader.java
For the RIA applications complete object tree should be initialized(To achieve that there is work around available like dpHibernate). But hibernate search doesn't apply criteria to queried result because it returns the result on the basis of wether objectt is intialized by loading the criteria objects.Since there is no lazy intiaialization so all the objects are loaded andcomplete result will be return irrespctive of criteria.
code snipet from Hibernate Search API(org.hibernate.search.engine.QueryLoader.java.):
public List load(EntityInfo... entityInfos) {
final int maxResults = entityInfos.length;
if ( maxResults == 0 ) return EMPTY_LIST;
if ( entityType == null ) throw new AssertionFailure( "EntityType not defined" );
if ( criteria == null ) criteria = session.createCriteria( entityType );
DocumentBuilder builder = searchFactoryImplementor.getDocumentBuilders().get( entityType );
String idName = builder.getIdentifierName();
int loop = maxResults / MAX_IN_CLAUSE;
boolean exact = maxResults % MAX_IN_CLAUSE == 0;
if ( !exact ) loop++;
Disjunction disjunction = Restrictions.disjunction();
for (int index = 0; index < loop; index++) {
int max = index * MAX_IN_CLAUSE + MAX_IN_CLAUSE <= maxResults ?
index * MAX_IN_CLAUSE + MAX_IN_CLAUSE :
maxResults;
List ids = new ArrayList( max - index * MAX_IN_CLAUSE );
for (int entityInfoIndex = index * MAX_IN_CLAUSE; entityInfoIndex < max; entityInfoIndex++) {
ids.add( entityInfos[entityInfoIndex].id );
}
disjunction.add( Restrictions.in( idName, ids ) );
}
criteria.add( disjunction );
criteria.list(); //load all objects
//mandatory to keep the same ordering
List result = new ArrayList( entityInfos.length );
for (EntityInfo entityInfo : entityInfos) {
Object element = session.load( entityInfo.clazz, entityInfo.id );
if ( Hibernate.isInitialized( element ) ) { //This is true for all the objects,in case objects are eagrly intialized
//all existing elements should have been loaded by the query,
//the other ones are missing ones
result.add( element );
}
}
return result;
}
--
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
14 years, 9 months
[Hibernate-JIRA] Created: (HSEARCH-362) When using hibernate-search3.1.0 GA, Search throws AlreadyClosedException under certain circumstances
by S Ravi Bhaskar (JIRA)
When using hibernate-search3.1.0 GA, Search throws AlreadyClosedException under certain circumstances
-----------------------------------------------------------------------------------------------------
Key: HSEARCH-362
URL: http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-362
Project: Hibernate Search
Issue Type: Bug
Components: directory provider
Affects Versions: 3.1.0.GA
Environment: Hibernate 3.2.6 GA, ant 1.7.1
Reporter: S Ravi Bhaskar
The below code throws an AlreadyClosedException when trying to open the lucene index. Junit test to test it works from eclipse, fails in an ant build.
I suspect it is trying to reuse a handle to the index. Please let me know if you need more information.
I had to bump back my hibernate search version to 3.0.1 GA, and then it started working. I am getting by, but would ideally like to use 3.1.0 GA without this exception. I think it has something to do with Search.getFullTextEntityManager((getJpaPersistenceContext().getEntityManager())); VS Search.createFullTextEntityManager((getJpaPersistenceContext().getEntityManager())); in the older version.
String query = "BlahBlahBlah";
org.apache.lucene.queryParser.QueryParser parser = new QueryParser("ItemTitle", new StandardAnalyzer() );
org.apache.lucene.search.Query luceneQuery;
try {
luceneQuery = parser.parse(query);
} catch (ParseException e) {
// TODO Auto-generated catch block
logger.error(String.format("Error parsing search querystring "));
return null;
}
javax.persistence.Query fullTextQuery = createFullTextEntityManager().createFullTextQuery(luceneQuery, klass);
List result = fullTextQuery.getResultList(); // return a list of managed
where createFullTextEntityManager() is
public FullTextEntityManager createFullTextEntityManager() {
return Search.getFullTextEntityManager((getJpaPersistenceContext().getEntityManager()));
}
--
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
14 years, 9 months
[Hibernate-JIRA] Created: (HSEARCH-396) disableFullTextFilter(String name) in FullTextQueryImpl does not disable the filter.
by wolfjourn (JIRA)
disableFullTextFilter(String name) in FullTextQueryImpl does not disable the filter.
------------------------------------------------------------------------------------
Key: HSEARCH-396
URL: http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-396
Project: Hibernate Search
Issue Type: Bug
Components: query
Affects Versions: 3.1.1.GA
Environment: Hibernate 3.3.2.GA
Hibernate Annotations 3.4.0.GA
RDBMS: MySQL, version: 5.0.70-log
JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-5.1.6
Reporter: wolfjourn
The disableFullTextFilter(String name) method in FullTextQueryImpl does not cause the filter to be disabled. This is due to incorrect logic in the buildFilters() method in the same class.
For example,
fullTextQuery = s.createFullTextQuery( query, Driver.class );
fullTextQuery.list().size(); /* Returns 10 */
fullTextQuery.enableFullTextFilter("security");
fullTextQuery.list().size(); /* Returns 5 */
fullTextQuery.disableFullTextFilter("security");
fullTextQuery.list().size(); /* Returns 5. Should return 10. */
Initially, buildFilters() constructs `filter' using the "security" filter from filterDefinitions. During the disableFullTextFilter("security") call, the filter is removed from `filterDefinitions'. However, `filter' remains intact. The subsequent call to buildFilters() returns immediately as `filterDefinitions' is now empty, leaving `filter' intact and thus not disabling the "security" filter. Furthermore, if a filter is disabled and replaced with another filter, the result will be a composition of both filters as towards the bottom of buildFilters(), any existing `filter' is chained onto the end of a new `chainedFilter'. This results in an empty result set if the sets returned by the filters are mutually exclusive.
It looks like this issue was resolved with revision 16755. However, this is still worth documenting here for other 3.1.1.GA users that might run into the same issue.
--
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
14 years, 9 months
[Hibernate-JIRA] Created: (HSEARCH-389) Filtering using criteria API is unreliable
by Dirk Mahler (JIRA)
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.1.GA, 3.1.0.GA
Environment: Hibernate 3.3.2.GA, Hibernate Entity Manager 3.4.0.GA, Oracle 9.2
Reporter: Dirk Mahler
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
14 years, 9 months