-->
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: INNER JOIN throws NullPointerException in HqlSqlWalker
PostPosted: Sat Feb 04, 2006 6:58 am 
Newbie

Joined: Tue Nov 16, 2004 10:18 pm
Posts: 8
I want to get the children of the Mother with the max name...
I can do a work around by getting the max from mother first, then getting her children, but I want to find out why the inner join is not working.
Thanks.

Hibernate version: 3.0

Mapping documents:
<!--MOTHER-->
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class
name="onetomany.Mother"
table="Mother">
<id name="id"
column="id"
type="java.lang.Long">
<generator class="native"></generator>
</id>

<property
name="name"
type="java.lang.String"
update="true"
insert="true"
column="name"/>

<list
name="children"
lazy="false"
cascade="save-update">

<key
column="FK_ONE"
>
</key>

<index
column="MANY_INDEX"
/>

<one-to-many
class="onetomany.Children"
/>

</list>
</class>

</hibernate-mapping>


<!--CHILDREN-->
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping
>
<class
name="onetomany.Children"
table="Children">
<id
name="id"
column="id"
type="java.lang.Long">
<generator class="native"></generator>
</id>

<property
name="name"
type="java.lang.String"
update="true"
insert="true"
column="name" />
</class>

<query name="getSomeone"><![CDATA[
SELECT max(b.name) FROM Children a INNER JOIN onetomany.Mother b
]]></query>

</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():
Query q=s.getNamedQuery("getSomeone");
List l=q.list();

Full stack trace of any exception that occurs:
Initial SessionFactory creation failed.java.lang.NullPointerException
java.lang.ExceptionInInitializerError
at util.HibernateUtil.<clinit>(HibernateUtil.java:16)
at onetomany.Join.main(Join.java:13)
Caused by: java.lang.NullPointerException
at org.hibernate.hql.ast.HqlSqlWalker.createFromJoinElement(HqlSqlWalker.java:264)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.joinElement(HqlSqlBaseWalker.java:3022)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:2841)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:2719)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:513)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:371)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:201)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:151)
at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:189)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:130)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:83)
at org.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:427)
at org.hibernate.impl.SessionFactoryImpl.checkNamedQueries(SessionFactoryImpl.java:388)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:291)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1005)
at util.HibernateUtil.<clinit>(HibernateUtil.java:13)
... 1 more
Exception in thread "main"

Name and version of the database you are using: MYSQL 5.0.16

The generated SQL (show_sql=true):NA

Debug level Hibernate log excerpt:

using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost/myhibernate
connection properties: {user=, password=}
schema export complete
cleaning up connection pool: jdbc:mysql://localhost/myhibernate
Checking 1 named queries


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.