[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-2536?page=c...
]
Diego Pires Plentz resolved HHH-2536.
-------------------------------------
Assignee: Diego Pires Plentz
Resolution: Duplicate
NPE with custom SQL query and formula property
----------------------------------------------
Key: HHH-2536
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-2536
Project: Hibernate3
Issue Type: Bug
Components: core
Affects Versions: 3.2.1
Reporter: Jörg Heinicke
Assignee: Diego Pires Plentz
Priority: Minor
I have an object Balance which I map like the following (stripped):
<class name="Balance" entity-name="Balance"
table="BALANCE">
...
<property name="reportDate" column="report_date"
type="..." not-null="true"/>
<property name="year" formula="year(report_date)"
type="..."/>
</class>
Now I have another object which is actually a cumulated view of the BALANCE table. For
retrieving the values I use a custom SQL query. The mapping is almost the same (it is at
least for the properties in question, but e.g. the ID mapping is different as it is a
cumulated view).
<class name="PaymentStatisticsData">
...
<property name="reportDate" column="report_date"
type="..." not-null="true"/>
<property name="year" formula="year(report_date)"
type="..."/>
<loader query-ref="paymentStatisticsData"/>
</class>
<sql-query name="paymentStatisticsData" read-only="true">
<return class="PaymentStatisticsData"/>
select ...
</sql-query>
In theory there should be no difference, but the latter fails with the following NPE:
Caused by: java.lang.NullPointerException
at org.hibernate.loader.DefaultEntityAliases.intern(DefaultEntityAliases.java:133)
at
org.hibernate.loader.DefaultEntityAliases.getSuffixedPropertyAliases(DefaultEntityAliases.java:106)
at org.hibernate.loader.DefaultEntityAliases.<init>(DefaultEntityAliases.java:52)
at org.hibernate.loader.ColumnEntityAliases.<init>(ColumnEntityAliases.java:16)
at
org.hibernate.loader.custom.sql.SQLQueryReturnProcessor.generateCustomReturns(SQLQueryReturnProcessor.java:174)
at org.hibernate.loader.custom.sql.SQLCustomQuery.<init>(SQLCustomQuery.java:129)
at
org.hibernate.engine.query.NativeSQLQueryPlan.<init>(NativeSQLQueryPlan.java:43)
at
org.hibernate.engine.query.QueryPlanCache.getNativeSQLQueryPlan(QueryPlanCache.java:114)
at org.hibernate.impl.SessionFactoryImpl.checkNamedQueries(SessionFactoryImpl.java:444)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:351)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1291)
Hope that's all information you need.
Joerg
--
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