Novo Objeto com HQL - NPE em StandardAnsiSqlAggregationFunctions, determineJdbcTypeCode
Eu sei que isso tem sidoperguntou muito, mas parece que estou tendo um problema diferente. Eu vi que existeum inseto no Hibernate que luta com um SumFunction ignorando tipos de usuários personalizados, mas eu não estou usando um tipo de usuário personalizado para o meu conhecimento. Eu estou basicamente tentando criar um novo objeto que é um roll-up de um bean de mapeamento existente, no entanto eu recebo umNullPointerException
contra alguma função de dialeto do Hibernate. Eu tentei usar tanto Double e BigDecimal como o meuvalue
tipo de campo, mas ambos fornecem a mesma mensagem de erro na implantação. Por favor ajude!
Aqui está um código:
Feijão Mapeado:
@Entity
@Table(name = "v_summary_report")
public class SummaryReportView implements java.io.Serializable {
private static final long serialVersionUID = 1L;
@Id
@Column(name = "id")
private String id;
@Column(name = "region")
private String region;
@Column(name = "market")
private String market;
@Column(name = "proj_year_month")
private String projectionYearMonth;
@OneToOne(cascade={CascadeType.DETACH})
@JoinColumn(name="attrib_id", referencedColumnName="attrib_id")
private Attribute attribute;
@Column(name = "total_value")
private BigDecimal value;
/* other stuff */
}
Consulta nomeada sendo chamada:
@NamedQuery(name = "findSummaryReportTotalByRegion", query = " SELECT new com.rac.projections.bean.SummaryReportTotal(srv.projectionYearMonth, srv.attribute, sum(value)) from SummaryReportView srv where srv.region = :region group by srv.projectionYearMonth, srv.attribute"),
Definição total do bean:
public class SummaryReportTotal {
private String projectionYearMonth;
private Attribute attribute;
private BigDecimal value;
public SummaryReportTotal() {
super();
}
public SummaryReportTotal(String projectionYearMonth, Attribute attribute, BigDecimal value) {
this.projectionYearMonth = projectionYearMonth;
this.attribute = attribute;
this.value = value;
}
/* other stuff */
}
Stacktrace:
Caused by: java.lang.NullPointerException
at org.hibernate.dialect.function.StandardAnsiSqlAggregationFunctions$SumFunction.determineJdbcTypeCode(StandardAnsiSqlAggregationFunctions.java:145)
at org.hibernate.dialect.function.StandardAnsiSqlAggregationFunctions$SumFunction.getReturnType(StandardAnsiSqlAggregationFunctions.java:157)
at org.hibernate.hql.internal.ast.util.SessionFactoryHelper.findFunctionReturnType(SessionFactoryHelper.java:406)
at org.hibernate.hql.internal.ast.tree.AggregateNode.getDataType(AggregateNode.java:83)
at org.hibernate.hql.internal.ast.tree.ConstructorNode.resolveConstructorArgumentTypes(ConstructorNode.java:166)
at org.hibernate.hql.internal.ast.tree.ConstructorNode.prepare(ConstructorNode.java:141)
at org.hibernate.hql.internal.ast.HqlSqlWalker.processConstructor(HqlSqlWalker.java:1019)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.selectExpr(HqlSqlBaseWalker.java:2150)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.selectExprList(HqlSqlBaseWalker.java:2016)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.selectClause(HqlSqlBaseWalker.java:1451)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:571)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:299)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:247)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:248)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:183)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:136)
at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:105)
at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:80)
at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:168)
at org.hibernate.internal.SessionFactoryImpl.checkNamedQueries(SessionFactoryImpl.java:1032)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:506)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1750)
at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:94)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:905)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:890)
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:74)
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:225)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:308)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)
... 45 more