[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-128?page=co...
]
Steve Ebersole closed HHH-128.
------------------------------
Closing stale resolved issues
NullPointerException when using a 'one-to-many bag' in a
'component' inside a 'dynamic-component'
-------------------------------------------------------------------------------------------------
Key: HHH-128
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-128
Project: Hibernate Core
Issue Type: Patch
Components: core
Affects Versions: 3.0 beta 4
Environment: Hibernate 3.0 beta 3, HSQLDB, Java 1.4
Reporter: Daniel Seiler
Assignee: Gavin King
Priority: Minor
Fix For: 3.0 beta 4
Attachments: dynamiccomponent-test.zip, dynamiccomponent-test2.zip
Original Estimate: 2h
Remaining Estimate: 2h
Problem:
When I call the method Configuration.addXML(...) with the mapping file showed below I get
a NullPointerException (see Stack Trace). The Exception seams only to occur if I try to
model a one to many relationship inside a component which is par of a dynamic component.
Possible Solution:
I figured out that if I change the code in the method
bindComponent(...) of the class org.hibernate.cfg.HbmBinder.java
from:
...
else if ( classNode != null ) {
component.setComponentClassName( getClassName( classNode, mappings ) );
}
...
to:
...
else if ( classNode != null ) {
parentClass = getClassName( classNode, mappings );
component.setComponentClassName( parentClass );
}
...
Since the NullPointer was caused by the parentClass that was null. I don't know if my
fix is the proper solution to the problem but I tried it out and it worked. Please have a
look.
thanks
Daniel
Mapping File:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD
3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping default-lazy="false">
<class name="ch.truesolutions.hibernate.Artifact" table="ZOO1"
entity-name="ZOO1">
<id name="id" type="long" unsaved-value="0" >
<generator class="native"/>
</id>
<dynamic-component name="groupLists">
<component name="address"
class="ch.truesolutions.hibernate.GroupList">
<bag name="groups"
cascade="save-update"
lazy="false">
<key column="ZOO1_ID"/>
<one-to-many entity-name="ADDRESS1"/>
</bag>
</component>
</dynamic-component>
</class>
<class name="ch.truesolutions.hibernate.Group"
entity-name="ADDRESS1" table="ADDRESS1" >
<id name="id" type="long" unsaved-value="0" >
<generator class="native"/>
</id>
...
</class>
</hibernate-mapping>
Full stack trace of any exception that occurs:
ERROR [main] (Configuration.java:304) - Could not configure datastore from XML
java.lang.NullPointerException
at org.hibernate.util.StringHelper.qualify(StringHelper.java:201)
at org.hibernate.cfg.HbmBinder.bindCollection(HbmBinder.java:914)
at org.hibernate.cfg.HbmBinder$4.create(HbmBinder.java:2193)
at org.hibernate.cfg.HbmBinder.bindComponent(HbmBinder.java:1287)
at org.hibernate.cfg.HbmBinder.bindComponent(HbmBinder.java:1315)
at org.hibernate.cfg.HbmBinder.createClassProperties(HbmBinder.java:1490)
at org.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:589)
at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:1848)
at org.hibernate.cfg.Configuration.add(Configuration.java:344)
at org.hibernate.cfg.Configuration.addXML(Configuration.java:301)
at ch.truesolutions.hibernate.HibernateHelper.<init>(HibernateHelper.java:65)
at ch.truesolutions.hibernate.HibernateHelper.getInstance(HibernateHelper.java:56)
at ch.truesolutions.hibernate.TestHibernate.main(TestHibernate.java:39)
ERROR [main] (HibernateHelper.java:77) - Building SessionFactory failed.
org.hibernate.MappingException: java.lang.NullPointerException
at org.hibernate.cfg.Configuration.addXML(Configuration.java:305)
at ch.truesolutions.hibernate.HibernateHelper.<init>(HibernateHelper.java:65)
at ch.truesolutions.hibernate.HibernateHelper.getInstance(HibernateHelper.java:56)
at ch.truesolutions.hibernate.TestHibernate.main(TestHibernate.java:39)
Caused by: java.lang.NullPointerException
at org.hibernate.util.StringHelper.qualify(StringHelper.java:201)
at org.hibernate.cfg.HbmBinder.bindCollection(HbmBinder.java:914)
at org.hibernate.cfg.HbmBinder$4.create(HbmBinder.java:2193)
at org.hibernate.cfg.HbmBinder.bindComponent(HbmBinder.java:1287)
at org.hibernate.cfg.HbmBinder.bindComponent(HbmBinder.java:1315)
at org.hibernate.cfg.HbmBinder.createClassProperties(HbmBinder.java:1490)
at org.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:589)
at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:1848)
at org.hibernate.cfg.Configuration.add(Configuration.java:344)
at org.hibernate.cfg.Configuration.addXML(Configuration.java:301)
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira