[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-6681) ArrayIndexOutOfBoundsException on enabling cache for a Native SQL query

songkun (JIRA) noreply at atlassian.com
Mon Oct 10 01:13:22 EDT 2011


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-6681?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=43978#comment-43978 ] 

songkun commented on HHH-6681:
------------------------------

	protected void autoDiscoverTypes(ResultSet rs) {
		try {
			Metadata metadata = new Metadata( getFactory(), rs );
			List aliases = new ArrayList();
			List types = new ArrayList();

			rowProcessor.prepareForAutoDiscovery( metadata );

			for ( int i = 0; i < rowProcessor.columnProcessors.length; i++ ) {
				rowProcessor.columnProcessors[i].performDiscovery( metadata, types, aliases );
			}
			//---------------------------------------------------
			// bug  here ??? copy types to resultTypes ,not "="  ?
			resultTypes = ArrayHelper.toTypeArray( types );
			transformerAliases = ArrayHelper.toStringArray( aliases );
		}
		catch ( SQLException e ) {
			throw new HibernateException( "Exception while trying to autodiscover types.", e );
		}
	}

> ArrayIndexOutOfBoundsException on enabling cache for a Native SQL query
> -----------------------------------------------------------------------
>
>                 Key: HHH-6681
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6681
>             Project: Hibernate Core
>          Issue Type: Bug
>          Components: caching (L2)
>    Affects Versions: 3.6.7
>         Environment: Hibernate 3.6.7-Final
> ehcache 2.4.5
>            Reporter: Samuel Mendenhall
>             Fix For: 3.6.8
>
>
> String sql = "select (SELECT count(*) from kcs.dw_reports as k, kcs.dw_link_rate as lr where k.id = lr.master_report_id and k.kerberos_name = :username and k.active = true and k.span_identifier = :yearMonth) as total," +
> 				"(SELECT count(*) from kcs.dw_reports as k, kcs.dw_link_rate as lr where k.id = lr.master_report_id and k.kerberos_name = :username and k.active = true and k.span_identifier = :yearMonth  and lr.linked_to_doc_id IS NULL) as unlinked";
> 		
> try 
> {
> 	beginTransaction();
> 	results = getSession().createSQLQuery(sql)
> 		.setParameter("username", username)
> 		.setParameter("yearMonth", yearMonth)
> 		.setCacheable(true)
> 		.setReadOnly(true)
> 		.list();
> 	commitTransaction();
> } 
> catch (HibernateException e) 
> {
> 	rollbackTransaction();
> 	e.printStackTrace();
> 	log.error(e.getMessage());
> }
> Console log:
> Hibernate: 
>     select
>         (SELECT
>             count(*) 
>         from
>             kcs.dw_reports as k,
>             kcs.dw_link_rate as lr 
>         where
>             k.id = lr.master_report_id 
>             and k.kerberos_name = ? 
>             and k.active = true 
>             and k.span_identifier = ?) as total,
>         (SELECT
>             count(*) 
>         from
>             kcs.dw_reports as k,
>             kcs.dw_link_rate as lr 
>         where
>             k.id = lr.master_report_id 
>             and k.kerberos_name = ? 
>             and k.active = true 
>             and k.span_identifier = ?  
>             and lr.linked_to_doc_id IS NULL) as unlinked
> 21:01:42,284 ERROR ViewLinkRateService:40 - 0
> java.lang.ArrayIndexOutOfBoundsException: 0
> 	at org.hibernate.type.TypeHelper.disassemble(TypeHelper.java:146)
> 	at org.hibernate.cache.StandardQueryCache.put(StandardQueryCache.java:106)
> 	at org.hibernate.loader.Loader.putResultInQueryCache(Loader.java:2434)
> 	at org.hibernate.loader.Loader.listUsingQueryCache(Loader.java:2321)
> 	at org.hibernate.loader.Loader.list(Loader.java:2268)
> 	at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:316)
> 	at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1842)
> 	at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:165)
> 	at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:157)
> 	at com.jboss.support.server.KcsDao.getDwLinkRateNative(KcsDao.java:69)
> 	at com.jboss.support.server.KcsDao.getLinkRateDataTable(KcsDao.java:128)
> 	at com.jboss.support.server.service.ViewLinkRateService$2.run(ViewLinkRateService.java:31)
> 	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
> 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
> 	at java.lang.Thread.run(Thread.java:680)

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list