[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-3051) NPE while query.list on a Native SQL, using L2 cache

Daniel Guggi (JIRA) noreply at atlassian.com
Thu Sep 1 09:02:03 EDT 2011


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

Daniel Guggi commented on HHH-3051:
-----------------------------------

The same problem exists with hibernate-entity-manager. (I did not find a way to define the scalar-type using jpa-api).
see you post in the form: https://forum.hibernate.org/viewtopic.php?f=1&t=1012471

As far as I can see 
* method Loader.listUsingQueryCache() gets invoked with method-argument "final Type[] resultTypes -> [] (empty array)"
* then (from listUsingQueryCache) Loader.doList() is invoked which further invoked doQueryAndInitializeNonLazyCollections() -> doQuery()
* from doQuery() -> method getResultSet() is invoked - from there autoDiscoverTypes() is invoked and "Loader.resultTypes instance-variable" is updated correctly
* However the method-argument "final Type[] resultTypes -> [] (empty array)" is then passed to putResultInQueryCache()

> NPE while query.list on a Native SQL, using L2 cache
> ----------------------------------------------------
>
>                 Key: HHH-3051
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3051
>             Project: Hibernate Core
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 3.2.5
>         Environment: Hibernate 3.2.5ga
> Database Oracle 9i
> Jdk  - 1.4.2_13
> EHCache 1.2.3 / OsCache 2.1 both
>            Reporter: Amit Kapoor
>         Attachments: NativeSQL-L2Cache-Issue.zip
>
>
> I get an NPE when i try to execute a native query.
> Below is the excerpt of the code that throws NPE:
> 		String sqlQuery = "select emp_id, emp_first_name from employee_mt";
> 		SQLQuery query = session.createSQLQuery(sqlQuery);
> 		query.setCacheable(true).setCacheRegion("TEST_REGION");
> 		query.addScalar("emp_id");
> 		query.addScalar("emp_first_name");
> 		List list = query.list();
> query.list() throws the following NPE:
> java.lang.NullPointerException
> 	at org.hibernate.type.TypeFactory.disassemble(TypeFactory.java:451)
> 	at org.hibernate.cache.StandardQueryCache.put(StandardQueryCache.java:83)
> 	at org.hibernate.loader.Loader.putResultInQueryCache(Loader.java:2194)
> 	at org.hibernate.loader.Loader.listUsingQueryCache(Loader.java:2138)
> 	at org.hibernate.loader.Loader.list(Loader.java:2096)
> 	at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:289)
> 	at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1695)
> 	at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:142)
> 	at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:152)
> 	at poc.hibernate.caching.QueryCaching.fireNativeSql(QueryCaching.java:112)
> 	at poc.hibernate.caching.QueryCaching.fireQuery(QueryCaching.java:38)
> 	at poc.hibernate.caching.QueryCaching.main(QueryCaching.java:27)
> I tried tracing through the Hibernate code code and saw that the types[] in the at the time of execution of types[i].disassemble( row[i], session, owner ) (TypeFactory.disassemble()) was holding both the types as null. 
> However before reaching that piece of code CustomLoader.autoDiscoverTypes(resultset) had already resolved the resultTypes to appropriate values.
> Hope this helps.

--
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