title: Spring boot application query - H2 Db NameGenerator.generateColumnNames - null
body: <p>I have a spring boot application with spring data which is connected to an oracle database. When the application load with the oracle connections it starts successfully. However for my integration test when I use H2 db the following query fails:</p>
  <pre><code>@Query(&quot;SELECT new dummy.domain.dto.RevenueCollDTO(sum(d.amount), &quot; +
          &quot;TO_CHAR(d.Id.date, 'MM'), d.Id.years)  FROM RevenueCollection d WHERE d.Id.date &quot; +
          &quot;BETWEEN TO_DATE(:startDate, 'YYYY-MM-DD') AND TO_DATE(:endDate, 'YYYY-MM-DD')&quot; +
          &quot; GROUP BY TO_CHAR(d.Id.date, 'MM'), d.Id.years ORDER BY d.Id.years ASC, TO_CHAR(d.Id.date, 'MM') ASC &quot;)
  List&lt;RevenueCollDTO&gt; getAllRevenueCollectionByDate(String startDate, String endDate);
  </code></pre>
  <p>The error log is shown below:</p>
  <pre><code>Caused by: java.lang.NullPointerException: null
      at org.hibernate.hql.internal.NameGenerator.generateColumnNames(NameGenerator.java:27)
      at org.hibernate.hql.internal.ast.util.SessionFactoryHelper.generateColumnNames(SessionFactoryHelper.java:434)
      at org.hibernate.hql.internal.ast.tree.SelectClause.initializeColumnNames(SelectClause.java:270)
      at org.hibernate.hql.internal.ast.tree.SelectClause.finishInitialization(SelectClause.java:260)
      at org.hibernate.hql.internal.ast.tree.SelectClause.initializeExplicitSelectClause(SelectClause.java:255)
      at org.hibernate.hql.internal.ast.HqlSqlWalker.useSelectClause(HqlSqlWalker.java:1026)
      at org.hibernate.hql.internal.ast.HqlSqlWalker.processQuery(HqlSqlWalker.java:794)
      at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:689)
      at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:325)
      at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:273)
      at org.hibernate.hql.internal.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:276)
      at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:192)
      at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:144)
      at org.hibernate.engine.query.spi.HQLQueryPlan.&lt;init&gt;(HQLQueryPlan.java:113)
      at org.hibernate.engine.query.spi.HQLQueryPlan.&lt;init&gt;(HQLQueryPlan.java:73)
      at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:162)
      at org.hibernate.internal.AbstractSharedSessionContract.getQueryPlan(AbstractSharedSessionContract.java:604)
      at org.hibernate.internal.AbstractSharedSessionContract.createQuery(AbstractSharedSessionContract.java:716)
      at org.hibernate.internal.AbstractSharedSessionContract.createQuery(AbstractSharedSessionContract.java:113)
      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.base/java.lang.reflect.Method.invoke(Method.java:564)
      at org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:366)
      at com.sun.proxy.$Proxy106.createQuery(Unknown Source)
      at org.springframework.data.jpa.repository.query.SimpleJpaQuery.validateQuery(SimpleJpaQuery.java:87)
      ... 114 common frames omitted
  </code></pre>
  <p>Please find my entity below:</p>
  <pre><code>    @Entity
  @Table(name = &quot;REVENUE_COLL&quot;)
  @Getter
  @Setter
  public class RevenueCollection {
      @EmbeddedId
      private Revenue Id;
  
      @Column(name = &quot;AMUNT&quot;)
      private Long amount;
  
      @Column(name = &quot;BDGETDES&quot;)
      private String budgetDesc;
  
      @Column(name = &quot;TXDESC&quot;)
      private String taxDesc;
  
  }
  
  
  @Embeddable
  @Getter
  @Setter
  public class Revenue implements Serializable {
      @Column(name = &quot;CODATE&quot;)
      private Date date;
  
      @Column(name = &quot;COYEAR&quot;)
      private int years;
  
      @Column(name = &quot;TAXCDE&quot;)
      private String taxCode;
      
      @Column(name = &quot;BDGTCDE&quot;)
      private String budgetCode;
  
  }
  </code></pre>
  <p>My integration test is define as below:</p>
  <pre><code>@ActiveProfiles(&quot;test&quot;)
  @SpringBootTest()
  public class ServiceTest {
  
      @Autowired
      private UserService userService;
  
      @Test
      @Sql(&quot;classpath:/sql/createUserFunction.sql&quot;)
       public void testUserInfo() throws Exception {
          
          userService.isUserValid(&quot;test&quot;,&quot;test&quot;);
        
      }
  
  }
  </code></pre>
  <p>Any idea why it is failing with H2 db please?</p>