-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Update queries generation bug
PostPosted: Wed Jul 30, 2008 2:21 pm 
Newbie

Joined: Fri Jul 27, 2007 5:48 pm
Posts: 4
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]


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 31, 2008 4:24 pm 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
NullPointerException means just that - you're putting something in there that is null.

Set a breakpoint and look at the values of the various variables as that particular line of code is called. You're calling methods on a null object, and getting this exception.

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.