I am evaluating the use of hibernator in eclipse, made a simple testproject and connection in the hibernate perspective, but after the connect! the mapping of one test class failed
I use:
eclipse Version: 2.1.2 Build id: 200311030802
MySql server 4.0.16-nt as target DB
I tried using different releases of hibernator (0.9.5 en 0.9.6 nolibs version), but all gave the same problem..
Has anyone come accross this problem and solved it?
Here's the stacktrace after the 'connect!':
Adding Project Classpath file:/C:/eclipse/workspace/TestHibernate/
Adding Mapping - C:/eclipse/workspace/TestHibernate/nl/zoefff/test/hibernate/Test.hbm.xml
java.lang.NullPointerException
at java.util.Hashtable.put(Unknown Source)
at java.util.Properties.setProperty(Unknown Source)
at net.sf.hibernate.cfg.Binder.makeIdentifier(Binder.java:835)
at net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:233)
at net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1095)
at net.sf.hibernate.cfg.Configuration.add(Configuration.java:230)
at net.sf.hibernate.cfg.Configuration.addFile(Configuration.java:155)
at net.sf.hibernator.HibernateConnection.createConnection(HibernateConnection.java:168)
at net.sf.hibernator.views.ConnectionView$8.run(ConnectionView.java:199)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:101)
rethrown as net.sf.hibernate.MappingException
at net.sf.hibernate.cfg.Configuration.addFile(Configuration.java:159)
at net.sf.hibernator.HibernateConnection.createConnection(HibernateConnection.java:168)
at net.sf.hibernator.views.ConnectionView$8.run(ConnectionView.java:199)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:101)
Caused by: java.lang.NullPointerException
at java.util.Hashtable.put(Unknown Source)
at java.util.Properties.setProperty(Unknown Source)
at net.sf.hibernate.cfg.Binder.makeIdentifier(Binder.java:835)
at net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:233)
at net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1095)
at net.sf.hibernate.cfg.Configuration.add(Configuration.java:230)
at net.sf.hibernate.cfg.Configuration.addFile(Configuration.java:155)
... 3 more
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
/*
*
* To change the template for this generated file go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
package nl.zoefff.test.hibernate;
/**
* Type description, responsibilities..
*
* @author mfr
* @version $revision$
*/
public class Test
{
private Long id;
private String name;
private String description;
/**
* Constructor for Test
*
*/
public Test()
{
super();
// TODO Auto-generated constructor stub
}
I solved the problem (partially), when exporting the schema externally (with the ExportSchema script) I discovered that the
MySql dialect doesn't understand sequence generator class, hilo works, I didn't test any other types of generator classes.. uuid should be useful
also when I compared some hbm.xml mappings from the reference doc (Employee) I saw the "name" attribuut on the param element was not set, maybe you need to generate it..
Finally I exported the class successfully to a table test in mysqldb (still) using the ExportScheme script,
One remark at some point there was a SaxParseException but it didn't influence the result
org.xml.sax.SAXParseException: The content of element type "class" must match "(
meta*,jcs-cache?,(id|composite-id),discriminator?,(version|timestamp)?,(property
|many-to-one|one-to-one|component|dynabean|any|map|set|list|bag|idbag|array|prim
itive-array)*,(subclass*|joined-subclass*))". at the "class" element
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
Maybe you have some suggestions about how to control the type of uid generator class, in the plugin I mean?
I saw one other possible defect in the eclipse Hibernator view. When I switch between the Java Editors the xml viewport becomes smaller..
cheers,
maarten
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2003-11-25
I too have a similar mapping issue with 0.9.6 and Oracle. Below is my class, Oracle table definition and mapping file.
class ErrorCode = {private int id;
private String progName;
private String errorCode;
private String errorText; }
I have defined corresp get/set methods as well.
The Oracle database table is defined as
ErrorCode {
SEQUENCENO NUMBER,
PROGNAME VARCHAR2(100),
ERRORCODE VARCHAR2(100),
ERRORTEXT VARCHAR2(500) }
The ErrorCode.hbm.xml is defined as
<hibernate-mapping>
<class name="com.nexgenix.ix.test.ErrorCode" table="ERRORCODE">
<id name="id">
<column name="SEQUENCENO" sql-type="NUMBER" not-null="true"/>
<generator class="sequence">
<param>seq_errorcode</param>
</generator>
</id>
And when I try to connect I get the exception
java.lang.NullPointerException
at java.util.Hashtable.put(Hashtable.java:398)
at java.util.Properties.setProperty(Properties.java:102)
at net.sf.hibernate.cfg.Binder.makeIdentifier(Binder.java:835)
at net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:233)
at net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1095)
at net.sf.hibernate.cfg.Configuration.add(Configuration.java:230)
at net.sf.hibernate.cfg.Configuration.addFile(Configuration.java:155)
at net.sf.hibernator.HibernateConnection.createConnection(HibernateConnection.java:168)
at net.sf.hibernator.views.ConnectionView$8.run(ConnectionView.java:199)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:101)
rethrown as net.sf.hibernate.MappingException
at net.sf.hibernate.cfg.Configuration.addFile(Configuration.java:159)
at net.sf.hibernator.HibernateConnection.createConnection(HibernateConnection.java:168)
at net.sf.hibernator.views.ConnectionView$8.run(ConnectionView.java:199)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:101)
Caused by: java.lang.NullPointerException
at java.util.Hashtable.put(Hashtable.java:398)
at java.util.Properties.setProperty(Properties.java:102)
at net.sf.hibernate.cfg.Binder.makeIdentifier(Binder.java:835)
at net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:233)
at net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1095)
at net.sf.hibernate.cfg.Configuration.add(Configuration.java:230)
at net.sf.hibernate.cfg.Configuration.addFile(Configuration.java:155)
... 3 more
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
hi,
I am evaluating the use of hibernator in eclipse, made a simple testproject and connection in the hibernate perspective, but after the connect! the mapping of one test class failed
I use:
eclipse Version: 2.1.2 Build id: 200311030802
MySql server 4.0.16-nt as target DB
I tried using different releases of hibernator (0.9.5 en 0.9.6 nolibs version), but all gave the same problem..
Has anyone come accross this problem and solved it?
Here's the stacktrace after the 'connect!':
Adding Project Classpath file:/C:/eclipse/workspace/TestHibernate/
Adding Mapping - C:/eclipse/workspace/TestHibernate/nl/zoefff/test/hibernate/Test.hbm.xml
java.lang.NullPointerException
at java.util.Hashtable.put(Unknown Source)
at java.util.Properties.setProperty(Unknown Source)
at net.sf.hibernate.cfg.Binder.makeIdentifier(Binder.java:835)
at net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:233)
at net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1095)
at net.sf.hibernate.cfg.Configuration.add(Configuration.java:230)
at net.sf.hibernate.cfg.Configuration.addFile(Configuration.java:155)
at net.sf.hibernator.HibernateConnection.createConnection(HibernateConnection.java:168)
at net.sf.hibernator.views.ConnectionView$8.run(ConnectionView.java:199)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:101)
rethrown as net.sf.hibernate.MappingException
at net.sf.hibernate.cfg.Configuration.addFile(Configuration.java:159)
at net.sf.hibernator.HibernateConnection.createConnection(HibernateConnection.java:168)
at net.sf.hibernator.views.ConnectionView$8.run(ConnectionView.java:199)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:101)
Caused by: java.lang.NullPointerException
at java.util.Hashtable.put(Unknown Source)
at java.util.Properties.setProperty(Unknown Source)
at net.sf.hibernate.cfg.Binder.makeIdentifier(Binder.java:835)
at net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:233)
at net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1095)
at net.sf.hibernate.cfg.Configuration.add(Configuration.java:230)
at net.sf.hibernate.cfg.Configuration.addFile(Configuration.java:155)
... 3 more
Maarten,
I would need to see your mapping file to be certain, but from the stack trace it looks as if your mapping file is missing an ID component.
Check the Hibernate doco (http://www.hibernate.org/hib_docs/reference/html/or-mapping.html#or-mapping-s1-4) for more details on this required tag.
For me .... I guess I need to include the id tag as part of the mapping file creation.
Daniel.
Hi daniel,
with respect to the failed mapping I include my simple test..
On your question if I had an id member added to the class my answer is yes..see below for further details.
Hope you come up with something,
cheers,
maarten
Hibernator connection properties
connection name=TestHibernate
driver class=com.mysql.jdbc.Driver
dialect=net.sf.hibernate.dialect.MySQLDialect
URL=jdbc:mysql://localhost/zoefff
driver filename=C:\java-apis\mysql-connector-java-3.0.9-stable\mysql-connector-java-3.0.9-stable-bin.jar
Source code
/*
*
* To change the template for this generated file go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
package nl.zoefff.test.hibernate;
/**
* Type description, responsibilities..
*
* @author mfr
* @version $revision$
*/
public class Test
{
private Long id;
private String name;
private String description;
/**
* Constructor for Test
*
*/
public Test()
{
super();
// TODO Auto-generated constructor stub
}
/**
* @return
*/
public String getDescription()
{
return description;
}
/**
* @return
*/
public Long getId()
{
return id;
}
/**
* @return
*/
public String getName()
{
return name;
}
/**
* @param string
*/
public void setDescription(String string)
{
description = string;
}
/**
* @param long1
*/
public void setId(Long long1)
{
id = long1;
}
/**
* @param string
*/
public void setName(String string)
{
name = string;
}
}
hi daniel,
I solved the problem (partially), when exporting the schema externally (with the ExportSchema script) I discovered that the
MySql dialect doesn't understand sequence generator class, hilo works, I didn't test any other types of generator classes.. uuid should be useful
also when I compared some hbm.xml mappings from the reference doc (Employee) I saw the "name" attribuut on the param element was not set, maybe you need to generate it..
Finally I exported the class successfully to a table test in mysqldb (still) using the ExportScheme script,
One remark at some point there was a SaxParseException but it didn't influence the result
org.xml.sax.SAXParseException: The content of element type "class" must match "(
meta*,jcs-cache?,(id|composite-id),discriminator?,(version|timestamp)?,(property
|many-to-one|one-to-one|component|dynabean|any|map|set|list|bag|idbag|array|prim
itive-array)*,(subclass*|joined-subclass*))". at the "class" element
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="nl.zoefff.test.hibernate.Test" table="test">
<property name="description"/>
<id name="id">
<generator class="hilo"/>
</id>
<property name="name"/>
</class>
</hibernate-mapping>
<!-- parsed in 0ms -->
Maybe you have some suggestions about how to control the type of uid generator class, in the plugin I mean?
I saw one other possible defect in the eclipse Hibernator view. When I switch between the Java Editors the xml viewport becomes smaller..
cheers,
maarten
I too have a similar mapping issue with 0.9.6 and Oracle. Below is my class, Oracle table definition and mapping file.
class ErrorCode = {private int id;
private String progName;
private String errorCode;
private String errorText; }
I have defined corresp get/set methods as well.
The Oracle database table is defined as
ErrorCode {
SEQUENCENO NUMBER,
PROGNAME VARCHAR2(100),
ERRORCODE VARCHAR2(100),
ERRORTEXT VARCHAR2(500) }
The ErrorCode.hbm.xml is defined as
<hibernate-mapping>
<class name="com.nexgenix.ix.test.ErrorCode" table="ERRORCODE">
<id name="id">
<column name="SEQUENCENO" sql-type="NUMBER" not-null="true"/>
<generator class="sequence">
<param>seq_errorcode</param>
</generator>
</id>
<property name="progName">
<column name="PROGNAME" sql-type="VARCHAR2(100)" not-null="false"/>
</property>
<property name="errorCode"/>
<property name="errorText"/>
</class>
</hibernate-mapping>
And when I try to connect I get the exception
java.lang.NullPointerException
at java.util.Hashtable.put(Hashtable.java:398)
at java.util.Properties.setProperty(Properties.java:102)
at net.sf.hibernate.cfg.Binder.makeIdentifier(Binder.java:835)
at net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:233)
at net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1095)
at net.sf.hibernate.cfg.Configuration.add(Configuration.java:230)
at net.sf.hibernate.cfg.Configuration.addFile(Configuration.java:155)
at net.sf.hibernator.HibernateConnection.createConnection(HibernateConnection.java:168)
at net.sf.hibernator.views.ConnectionView$8.run(ConnectionView.java:199)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:101)
rethrown as net.sf.hibernate.MappingException
at net.sf.hibernate.cfg.Configuration.addFile(Configuration.java:159)
at net.sf.hibernator.HibernateConnection.createConnection(HibernateConnection.java:168)
at net.sf.hibernator.views.ConnectionView$8.run(ConnectionView.java:199)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:101)
Caused by: java.lang.NullPointerException
at java.util.Hashtable.put(Hashtable.java:398)
at java.util.Properties.setProperty(Properties.java:102)
at net.sf.hibernate.cfg.Binder.makeIdentifier(Binder.java:835)
at net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:233)
at net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1095)
at net.sf.hibernate.cfg.Configuration.add(Configuration.java:230)
at net.sf.hibernate.cfg.Configuration.addFile(Configuration.java:155)
... 3 more
Looks like you're missing a name attribute to your param tag
try
<param name="sequence">seq_errorcode</param>
Let me know how you go
Hi Daniel,
Thanks! I added the 'name' attribute and it worked! The autogenerated file did not have the attribute and I missed it too.