[hibernate-issues] [Hibernate-JIRA] Resolved: (HSEARCH-305) Hibernate search doesn't work with criteria when it is not initialized laziily

Emmanuel Bernard (JIRA) noreply at atlassian.com
Thu Apr 8 11:39:42 EDT 2010


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

Emmanuel Bernard resolved HSEARCH-305.
--------------------------------------

       Resolution: Fixed
    Fix Version/s: 3.2.0.CR1

I think this bug is no more in the latest incarnation of the code. Reopen if needed.

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

        


More information about the hibernate-issues mailing list