title: Native SQL query for an Hibernate entity using @Formula results in NullPointerException
body: <p>I've got an simple Hibernate entity for which I use the @Formula annotion:</p>
  
  <pre><code>    @Id
  private Long id;
  
  private String name;
  
  @Formula("(select count(f.*) from foo f where f.id = id)")
  private long bar;
  </code></pre>
  
  <p>When I try to load an entity with a native SQL Query:</p>
  
  <pre><code>EM.createNativeQuery("SELECT f.*, count(something) as bar FROM foo f WHERE f.name = '...'", Entity.class)
  </code></pre>
  
  <p>I get an NullPointerException:</p>
  
  <pre><code>java.lang.NullPointerException
  at org.hibernate.loader.DefaultEntityAliases.intern(DefaultEntityAliases.java:193)
  at org.hibernate.loader.DefaultEntityAliases.getSuffixedPropertyAliases(DefaultEntityAliases.java:151)
  at org.hibernate.loader.DefaultEntityAliases.determinePropertyAliases(DefaultEntityAliases.java:93)
  at org.hibernate.loader.DefaultEntityAliases.&lt;init&gt;(DefaultEntityAliases.java:65)
  at org.hibernate.loader.ColumnEntityAliases.&lt;init&gt;(ColumnEntityAliases.java:45)
  at org.hibernate.loader.custom.sql.SQLQueryReturnProcessor.generateCustomReturns(SQLQueryReturnProcessor.java:197)
  at org.hibernate.loader.custom.sql.SQLCustomQuery.&lt;init&gt;(SQLCustomQuery.java:152)
  at org.hibernate.engine.query.NativeSQLQueryPlan.&lt;init&gt;(NativeSQLQueryPlan.java:67)
  at org.hibernate.engine.query.QueryPlanCache.getNativeSQLQueryPlan(QueryPlanCache.java:140)
  at org.hibernate.impl.AbstractSessionImpl.getNativeSQLQueryPlan(AbstractSessionImpl.java:160)
  at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:165)
  at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:179)
  at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:236)
  </code></pre>
  
  <p>When I remove the @Formula attribute all works fine.</p>
  
  <p>I found this bug report: <a href="https://hibernate.atlassian.net/browse/HHH-2536" rel="noreferrer">BugReport</a>. But for me it's not clear how to solve my problem.</p>