It is the first time I user hibernate. The information about the errors is below.
If I only use the "class"-declaration of sa.bo.UserDAO in the XML file no errors occur but I don't see any errors in the sa.bo.TrainingDAO.
Mapping documents:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping SYSTEM "hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="sa.bo.UserDAO" table="saTaUser">
<id name="Id" >
<column name="sUserId" not-null="true"/>
</id>
<property name="Vorname">
<column name="sVorname" length="60" not-null="false" />
</property>
<property name="Nachname">
<column name="sNachname" length="60" not-null="false" />
</property>
<property name="Plz">
<column name="sPlz" length="30" not-null="false" />
</property>
<property name="Ort">
<column name="sOrt" length="60" not-null="false" />
</property>
<property name="Strasse">
<column name="sStrasse" length="60" not-null="false" />
</property>
</class>
<class name="sa.bo.TrainingDAO" table="saTaTraining">
<property name="EinheitStart">
<column name="tEinheitStart" not-null="false" />
</property>
<property name="EinheitEnde">
<column name="tEinheitEnde" not-null="false" />
</property>
<property name="Beschreibung">
<column name="sBeschreibung" length="240" not-null="false" />
</property>
<property name="AnzahlKm">
<column name="nAnzahlKm" not-null="false" />
</property>
<property name="UserId">
<column name="sUserId" length="10" not-null="false" />
</property>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():Code:
Session oSession = HibernateUtil.currentSession();
oSession.beginTransaction();
oNewUser.setId(sId);
oNewUser.setVorname(sVorname);
oNewUser.setNachname(sNachname);
oNewUser.setPlz(sPlz);
oNewUser.setOrt(sOrt);
oNewUser.setStrasse(sStrasse);
oSession.save(oNewUser);
oSession.getTransaction().commit();
HibernateUtil.closeSession();
Full stack trace of any exception that occurs:Code:
log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" java.lang.ExceptionInInitializerError
at util.HibernateUtil.<clinit>(HibernateUtil.java:39)
at sa.admin.Userverwaltung.insert(Userverwaltung.java:170)
at sa.admin.Userverwaltung.main(Userverwaltung.java:49)
Caused by: org.hibernate.MappingException: Could not read mappings from resource: User.hbm.xml
at org.hibernate.cfg.Configuration.addResource(Configuration.java:485)
at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1465)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1433)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1414)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1390)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1310)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1296)
at util.HibernateUtil.<clinit>(HibernateUtil.java:34)
... 2 more
Caused by: org.hibernate.MappingException: invalid mapping
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:425)
at org.hibernate.cfg.Configuration.addResource(Configuration.java:482)
... 9 more
Caused by: org.xml.sax.SAXParseException: The content of element type "class" must match "(meta*,subselect?,cache?,synchronize*,comment?,(id|composite-id),discriminator?,natural-id?,(version|timestamp)?,(property|many-to-one|one-to-one|component|dynamic-component|properties|any|map|set|list|bag|idbag|array|primitive-array|query-list)*,((join*,subclass*)|joined-subclass*|union-subclass*),loader?,sql-insert?,sql-update?,sql-delete?,filter*)".
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.handleEndElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.endElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
at org.dom4j.io.SAXReader.read(SAXReader.java:465)
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:422)
... 10 more
Name and version of the database you are using:
HSQL