-->
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.  [ 3 posts ] 
Author Message
 Post subject: hbm2ddl NullPointerException
PostPosted: Thu May 20, 2004 1:34 pm 
Newbie

Joined: Thu May 20, 2004 12:24 pm
Posts: 9
Location: Brazil
Hi all,

I'm using this forum as a last resort, as it seems nobody has had a similar problem so far.
Well, I'm trying to do something that I thought it would be very very simple - create a class that contains a persistent map that indexes it's children by strings. I'm using Hibernate 2.1.3 over PostGRESQL 7.3.2.

Ladies and gents, my code:

First, my Parent class mapping file:

Code:

<?xml version="1.0"?>

<!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 1.1//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-1.1.dtd">

<hibernate-mapping>
    <class
        name="business.Clientes"
        table="CLIENTES"
    >

        <id
            name="id"
            column="parent_id"
            type="long"
        >
            <generator class="native">
            </generator>
        </id>

        <property
            name="nome"
            type="java.lang.String"
            column="NOME"
        />

        <map
            role="pessoaMap"
            lazy="true"
            cascade="save-update"
        >
              <key column="parent_id"/>
              <index column="nome" type="string" />
              <one-to-many class="business.Pessoa" />
        </map>

    </class>

</hibernate-mapping>



And now my child class mapping file:

Code:

<?xml version="1.0"?>

<!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 1.1//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-1.1.dtd">

<hibernate-mapping>
    <class
        name="business.Pessoa"
        table="PESSOA"
    >

        <id
            name="id"
            column="ID"
            type="long"
        >
            <generator class="native">
            </generator>
        </id>

        <many-to-one
            name="parent"
            class="business.Clientes"
            cascade="none"
            outer-join="auto"
            column="parent_id"
        />

        <property
            name="nome"
            type="java.lang.String"
            column="NOME"
        />

    </class>

</hibernate-mapping>



And finally, my problem - whenever I run the SchemaExport tool (I've adapted the script to run under Linux), I get this hard-to-decode exception:

Code:

INFO: Mapping class: business.Clientes -> CLIENTES
20/05/2004 14:25:07 net.sf.hibernate.cfg.Configuration addFile
SEVERE: Could not configure datastore from file: Clientes.hbm.xml
java.lang.NullPointerException
        at net.sf.hibernate.util.StringHelper.qualify(StringHelper.java:241)
        at net.sf.hibernate.cfg.Binder.bindCollection(Binder.java:498)
        at net.sf.hibernate.cfg.Binder$1.create(Binder.java:1414)
        at net.sf.hibernate.cfg.Binder.propertiesFromXML(Binder.java:1017)
        at net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:361)
        at net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1243)
        at net.sf.hibernate.cfg.Configuration.add(Configuration.java:249)
        at net.sf.hibernate.cfg.Configuration.addFile(Configuration.java:171)
        at net.sf.hibernate.tool.hbm2ddl.SchemaExport.main(SchemaExport.java:289)
20/05/2004 14:25:07 net.sf.hibernate.tool.hbm2ddl.SchemaExport main
SEVERE: Error creating schema
net.sf.hibernate.MappingException: java.lang.NullPointerException
        at net.sf.hibernate.cfg.Configuration.addFile(Configuration.java:176)
        at net.sf.hibernate.tool.hbm2ddl.SchemaExport.main(SchemaExport.java:289)
Caused by: java.lang.NullPointerException
        at net.sf.hibernate.util.StringHelper.qualify(StringHelper.java:241)
        at net.sf.hibernate.cfg.Binder.bindCollection(Binder.java:498)
        at net.sf.hibernate.cfg.Binder$1.create(Binder.java:1414)
        at net.sf.hibernate.cfg.Binder.propertiesFromXML(Binder.java:1017)
        at net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:361)
        at net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1243)
        at net.sf.hibernate.cfg.Configuration.add(Configuration.java:249)
        at net.sf.hibernate.cfg.Configuration.addFile(Configuration.java:171)
        ... 1 more
net.sf.hibernate.MappingException: java.lang.NullPointerException
        at net.sf.hibernate.cfg.Configuration.addFile(Configuration.java:176)
        at net.sf.hibernate.tool.hbm2ddl.SchemaExport.main(SchemaExport.java:289)
Caused by: java.lang.NullPointerException
        at net.sf.hibernate.util.StringHelper.qualify(StringHelper.java:241)
        at net.sf.hibernate.cfg.Binder.bindCollection(Binder.java:498)
        at net.sf.hibernate.cfg.Binder$1.create(Binder.java:1414)
        at net.sf.hibernate.cfg.Binder.propertiesFromXML(Binder.java:1017)
        at net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:361)
        at net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1243)
        at net.sf.hibernate.cfg.Configuration.add(Configuration.java:249)
        at net.sf.hibernate.cfg.Configuration.addFile(Configuration.java:171)
        ... 1 more



Maybe I got the index/element semantics all wrong, but even if I did, NullPointerException seems kinda strange.
Not that I like to brag about it, but I've been on top of this for two days and couldn't figure it out so far. If you need more details, I'll be glad to supply them.

Thanks in advance,

Giuliano


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 20, 2004 7:31 pm 
Newbie

Joined: Thu May 20, 2004 12:24 pm
Posts: 9
Location: Brazil
Strangely enough, this bizarre behaviour was due to an incorrect header that XDoclet was generating. XDoclet was using an old version of the DDL, probably because my version (of XDoclet) is a bit old as well.
All I had to do was switch my XDoclet-generated header:

Code:
  <!DOCTYPE hibernate-mapping PUBLIC
       "-//Hibernate/Hibernate Mapping DTD 1.1//EN"
       "http://hibernate.sourceforge.net/hibernate-mapping-1.1.dtd">


for

Code:
  <!DOCTYPE hibernate-mapping PUBLIC
       "-//Hibernate/Hibernate Mapping DTD//EN"
       "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">


I guess that NullPointerException was a bug in my brains after all. Still, I think it's a bit odd that a wrong DDL caused it to be raised.

Cheers,

Giuliano


Top
 Profile  
 
 Post subject: Thankyou!
PostPosted: Thu Dec 02, 2004 7:46 am 
Newbie

Joined: Thu Dec 02, 2004 6:27 am
Posts: 10
I had exactly this problem on one of my test machines and couldn't fathom why. The wrong version of XDoclet explains exactly why!!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.