I am new to Hibernate and I cannot figure out what is going on. I use Netbans and the pointbase database which is bundled with the Sun Java Application Server.
I have a simple table HIBTEST which has two fields (ID (PK),NAME ). I try to create a simple application that will just save an object to the database.
My POJO java class is Hibtest.java :
package hib;
public class Hibtest {
private String id;
private String name;
public String getId(){
return this.id;
}
public String getName(){
return this.name;
}
private void setId(String id){
this.id=id;
}
public void setName(String name){
this.name=name;
}
}
My Hibtest.hbm.xml file is:
<!DOCTYPE hibernate-mapping PUBLIC '-//Hibernate/Hibernate Mapping DTD//EN' 'http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd'>
<hibernate-mapping>
<class name="hib.Hibtest" table="HIBTEST">
<id name="id" type="string">
<generator class="increment"/>
</id>
<property name="name">
</property>
</class>
</hibernate-mapping>
My hibernate.cfg.xml file is:
<!DOCTYPE hibernate-configuration PUBLIC '-//Hibernate/Hibernate Configuration DTD//EN' 'http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd'>
<hibernate-configuration>
<session-factory>
<property name="connection.url">jdbc:pointbase://localhost:9092/sample</property>
<property name="connection.driver_class">com.pointbase.jdbc.jdbcUniversalDriver</property>
<property name="dialect">net.sf.hibernate.dialect.HSQLDialect</property>
<property name="connection.username">pbpublic</property>
<property name="connection.password">pbpublic</property>
<property name="show_sql">false</property>
<mapping resource="hib/Hibtest.hbm.xml"/>
</session-factory>
</hibernate-configuration>
They all seem simple and right.But when i try to run the project i get an error net.sf.hibernate.MappingException: duplicate import. The output is :
21-Jun-2005 15:03:50 net.sf.hibernate.cfg.Environment <clinit>
INFO: Hibernate 2.1.8
21-Jun-2005 15:03:50 net.sf.hibernate.cfg.Environment <clinit>
INFO: loaded properties from resource hibernate.properties: {hibernate.connection.username=pbpublic, hibernate.connection.password=pbpublic, hibernate.cglib.use_reflection_optimizer=true, hibernate.dialect=net.sf.hibernate.dialect.HSQLDialect# Sample ResourceBundle properties file, hibernate.connection.url=jdbc:pointbase://localhost:9092/sample, hibernate.connection.driver_class=com.pointbase.jdbc.jdbcUniversalDriver}
21-Jun-2005 15:03:50 net.sf.hibernate.cfg.Environment <clinit>
INFO: using CGLIB reflection optimizer
21-Jun-2005 15:03:50 net.sf.hibernate.cfg.Environment <clinit>
INFO: using JDK 1.4 java.sql.Timestamp handling
21-Jun-2005 15:03:50 net.sf.hibernate.cfg.Configuration addClass
INFO: Mapping resource: hib/Hibtest.hbm.xml
21-Jun-2005 15:03:51 net.sf.hibernate.cfg.Binder bindRootClass
INFO: Mapping class: hib.Hibtest -> HIBTEST
21-Jun-2005 15:03:51 net.sf.hibernate.cfg.Configuration configure
INFO: configuring from resource: /hibernate.cfg.xml
21-Jun-2005 15:03:51 net.sf.hibernate.cfg.Configuration getConfigurationInputStream
INFO: Configuration resource: /hibernate.cfg.xml
21-Jun-2005 15:03:51 net.sf.hibernate.cfg.Configuration addResource
INFO: Mapping resource: hib/Hibtest.hbm.xml
21-Jun-2005 15:03:51 net.sf.hibernate.cfg.Configuration add
SEVERE: Could not compile the mapping document
net.sf.hibernate.MappingException: duplicate import: Hibtest
at net.sf.hibernate.cfg.Mappings.addImport(Mappings.java:85)
Error reading resource: hib/Hibtest.hbm.xml
at net.sf.hibernate.cfg.Binder.bindClass(Binder.java:126)
at net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:221)
at net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1256)
at net.sf.hibernate.cfg.Configuration.add(Configuration.java:253)
at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:289)
at net.sf.hibernate.cfg.Configuration.addResource(Configuration.java:337)
at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:1027)
at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:983)
at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:911)
at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:897)
at hibernateearth.Main.main(Main.java:43)
Can anybody help me with this?
thank you
|