java.lang.NullPointerException

Hibernate JIRA | Amit Kapoor | 9 years ago
  1. 0

    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.

    Hibernate JIRA | 9 years ago | Amit Kapoor
    java.lang.NullPointerException
  2. 0

    Hibernate NullPointerException In Loader Class

    Stack Overflow | 7 years ago | SteveT
    java.lang.NullPointerException
  3. 0

    Hibernate ehCache null pointer exception on put

    Stack Overflow | 5 years ago | kgibbon
    java.lang.NullPointerException
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    A NullPointerException is thrown when hibernate.show_sql=true && hibernate.format_sql=true while exec'ing sql with quotes around the stmt: (taken from an embedded groovy script) --------- def sess = getSession() def HQL = """ (select count(*) from TABLE) """ sess .createSQLQuery(HQL) .list() ------------ This is valid SQL and is typically used in my app as such: (select count(*) from TABLE1) UNION ALL (select count(*) from TABLE2) ... Here is the stack trace in hibernate: java.lang.NullPointerException at org.hibernate.pretty.Formatter.isFunctionName(Formatter.java:342) at org.hibernate.pretty.Formatter.openParen(Formatter.java:323) at org.hibernate.pretty.Formatter.format(Formatter.java:134) at org.hibernate.jdbc.AbstractBatcher.format(AbstractBatcher.java:410) at org.hibernate.jdbc.AbstractBatcher.log(AbstractBatcher.java:404) at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:482) at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:423) at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:139) at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1547) at org.hibernate.loader.Loader.doQuery(Loader.java:673) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236) at org.hibernate.loader.Loader.doList(Loader.java:2220) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104) at org.hibernate.loader.Loader.list(Loader.java:2099) 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)

    Hibernate JIRA | 8 years ago | Scott Feldstein
    java.lang.NullPointerException

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.NullPointerException

      No message provided

      at org.hibernate.type.TypeFactory.disassemble()
    2. Hibernate
      CustomLoader.list
      1. org.hibernate.type.TypeFactory.disassemble(TypeFactory.java:451)
      2. org.hibernate.cache.StandardQueryCache.put(StandardQueryCache.java:83)
      3. org.hibernate.loader.Loader.putResultInQueryCache(Loader.java:2194)
      4. org.hibernate.loader.Loader.listUsingQueryCache(Loader.java:2138)
      5. org.hibernate.loader.Loader.list(Loader.java:2096)
      6. org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:289)
      6 frames
    3. Hibernate
      SQLQueryImpl.list
      1. org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1695)
      2. org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:142)
      3. org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:152)
      3 frames
    4. poc.hibernate.caching
      QueryCaching.main
      1. poc.hibernate.caching.QueryCaching.fireNativeSql(QueryCaching.java:112)
      2. poc.hibernate.caching.QueryCaching.fireQuery(QueryCaching.java:38)
      3. poc.hibernate.caching.QueryCaching.main(QueryCaching.java:27)
      3 frames