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