I am using Hibernate version 3.2.6.ga and it failed to generate update query for entity with formula property
Here is the query
Code:
update model.Store s set s.version = :version where s.containerId = :containerId and s.guid = :guid
containerId is a formula property
The mappings are:
Code:
<hibernate-mapping>
<class name="model.Container" table="container">
<id name="id" column="container_id" type="int" unsaved-value="0">
<generator class="native"/>
</id>
<set name="dataContainers" lazy="true" cascade="all-delete-orphan" sort="unsorted" batch-size="20">
<key column="container_id"/>
<one-to-many class="model.Store"/>
</set>
</hibernate-mapping>
<hibernate-mapping>
<class name="model.Store" table="store">
<id name="id" column="store_id" type="int" unsaved-value="0">
<generator class="native"/>
</id>
<property name="guid" type="java.lang.String" update="true" insert="true" column="store_guid"/>
<property name="version" type="java.lang.String" update="true" insert="true" column="store_version"/>
<property name="containerId" type="java.lang.Long" formula="(container_id)" update="false" insert="false"/>
</hibernate-mapping>
Hibernate successfully generates SELECT queries but fails with UPDATE
Code:
java.lang.NullPointerException
at org.hibernate.util.StringHelper.join(StringHelper.java:34)
at org.hibernate.hql.ast.tree.DotNode.initText(DotNode.java:231)
at org.hibernate.hql.ast.tree.DotNode.resolve(DotNode.java:224)
at org.hibernate.hql.ast.tree.FromReferenceNode.resolve(FromReferenceNode.java:94)
at org.hibernate.hql.ast.tree.FromReferenceNode.resolve(FromReferenceNode.java:90)
at org.hibernate.hql.ast.HqlSqlWalker.resolve(HqlSqlWalker.java:728)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.expr(HqlSqlBaseWalker.java:1216)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.exprOrSubquery(HqlSqlBaseWalker.java:4041)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.comparisonExpr(HqlSqlBaseWalker.java:3525)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1762)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1690)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.whereClause(HqlSqlBaseWalker.java:776)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.updateStatement(HqlSqlBaseWalker.java:358)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:237)
at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:228)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:160)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:111)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:77)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:56)
[/b]