[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-3051?page=c...
]
Amit Kapoor commented on HHH-3051:
----------------------------------
Additional Notes:
- I'm trying to use the query caching feature
- I'm firing native sql through hibernate
- I'm mapping the query result to scalar values
- I'm trying to use the auto discover types feature for scalar return type. Using
method Query.addScalar(String);
This is when the NPE is thrown. (I tried it with both EHCache provider and OSCache
provider and the NPE ocurred in both the cases.)
An NPE wasn't thrown in the following conditions:
-No query caching set
-When query caching was set but i used Query.addScalar(String, Type);
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: Hibernate3
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.
-
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