-->
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.  [ 1 post ] 
Author Message
 Post subject: select clause can cause exception - parser problem?
PostPosted: Mon Jan 23, 2006 5:27 am 
Expert
Expert

Joined: Tue Nov 23, 2004 7:00 pm
Posts: 570
Location: mostly Frankfurt Germany
When I write my query like
Code:
select o from Order o left join fetch o.orderLines where o.orderLines.quantity=5

the exception mentioned below is shown. the following works
Code:
from Order o left join fetch o.orderLines where o.orderLines.quantity=5


I thought that both queries are correct. If I am correct, than
I assume that this points to a problem in the parsing for a specific mapping.
When I change my mapping from a composite-element to a simple 1:n mapping for Order and OrderLine both query works.

See below my orginial mapping.
Code:
<hibernate-mapping package="de.laliluna.webstock">
  <class name="Order" table="torder">
    <id name="id">
      <generator class="sequence">
        <param name="sequence">torder_id_seq</param>
      </generator>
    </id>
    <property name="number" type="string"></property>
     <many-to-one name="customer" class="Customer">
      <column name="customer_id" not-null="true"></column>
    </many-to-one>
   
    <list name="orderLines" table="torderline" cascade="all-delete-orphan">
    <key column="order_id"></key>
      <list-index column="list_index"></list-index>
      <composite-element  class="OrderLine"  >
        <parent name="Order"  />
        <property name="quantity" type="integer"></property>
        <many-to-one name="article" column="article_id" class="Article" cascade="all"></many-to-one>
      </composite-element>
    </list>
  </class>

and the 1:n mapping which does not cause the problem.
Code:
<hibernate-mapping package="de.laliluna.webstock">
  <class name="Order" table="torder">
    <id name="id">
      <generator class="sequence">
        <param name="sequence">torder_id_seq</param>
      </generator>
    </id>
    <property name="number" type="string"></property>
     <many-to-one name="customer" class="Customer">
      <column name="customer_id" not-null="true"></column>
    </many-to-one>
   
    <list name="orderLines" table="torderline" cascade="all-delete-orphan">
    <key column="order_id"></key>
      <list-index column="list_index"></list-index>
      <one-to-many class="OrderLine"/>
    </list>
  </class>

  <class name="OrderLine" table="torderline">
    <id name="id">
      <generator class="sequence">
        <param name="sequence">torderline_id_seq</param>
      </generator>
    </id>

    <property name="quantity" type="integer"></property>

  </class>



Exception
Code:
10:10:27,000 DEBUG Collections:176 - Collection found: [de.lalilunaException in thread "main" java.lang.NullPointerException
   at org.hibernate.hql.ast.tree.SelectClause.initializeExplicitSelectClause(SelectClause.java:175)
   at org.hibernate.hql.ast.HqlSqlWalker.useSelectClause(HqlSqlWalker.java:637)
   at org.hibernate.hql.ast.HqlSqlWalker.processQuery(HqlSqlWalker.java:466)
   at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:643)
   at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:279)
   at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:227).webstock.Customer.orders#1], was: [de.laliluna.webstock.Customer.orders#1] (uninitialized)

_________________
Best Regards
Sebastian
---
Training for Hibernate and Java Persistence
Tutorials for Hibernate, Spring, EJB, JSF...
eBook: Hibernate 3 - DeveloperGuide
Paper book: Hibernate 3 - Das Praxisbuch
http://www.laliluna.de


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

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.