Zaczynam raczkować w bibliotece hibernate i na mojej drodze pojawiły się problemy. Stworzyłem bazę danych, stworzyłem klasy, przeprowadziłem mapowanie wg poradników znalezionych w internecie i jednak nadal posiadam problemy, i mam wrażenie że z mapowaniem.
Klasa :
public class Wozek implements Serializable {
private int ID;
private String NumerSeryjny;
private Date PoczatekWynajmu;
private Date KoniecWynajmu;
private float Limit;
private float KosztWynajmu;
private int NumerZakladowy;
private boolean StanNapraw;
private boolean Blokada;
private int ObecnyPrzebieg;
private String Typ;
private int IloscPaliwa;
public Wozek() {
}
....
Mapowanie:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<id column="ID" name="ID" type="integer">
<generator class="wozek">
<param name="ID">ID</param>
</generator>
</id>
<property column="NumerSeryjny" name="NumerSeryjny" not-null="true" type="string"/>
<property column="PoczatekWynajmu" name="PoczatekWynajmu" not-null="true" type="date"/>
<property column="KoniecWynajmu" name="KoniecWynajmu" not-null="true" type="date"/>
<property column="Limit" name="Limit" not-null="true" type="float"/>
<property column="KosztWynajmu" name="KosztWynajmu" not-null="true" type="float"/>
<property column="NumerZakladowy" name="NumerZakladowy" not-null="true" type="integer"/>
<property column="StanNapraw" name="StanNapraw" not-null="true" type="integer"/>
<property column="Blokada" name="Blokada" not-null="true" type="integer"/>
<property column="ObecnyPrzebieg" name="ObecnyPrzebieg" not-null="true" type="integer"/>
<property column="Typ" name="Typ" not-null="true" type="string"/>
<property column="IloscPaliwa" name="IloscPaliwa" not-null="true" type="integer"/>
</class>
</hibernate-mapping>
główny program:
Session session = new
Configuration().configure().buildSessionFactory().openSession();
Query qry = session.createQuery("from wozek");
ArrayList<Wozek> wozki = (ArrayList<Wozek>) qry.list();
session.close();
for(int i=0; i>wozki.size();i++)
{
System.out.print(wozki.get(i));
}
logi błędów :
lip 10, 2013 10:00:12 AM org.hibernate.annotations.common.Version <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {4.0.2.Final}
lip 10, 2013 10:00:12 AM org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {4.2.3.Final}
lip 10, 2013 10:00:12 AM org.hibernate.cfg.Environment <clinit>
INFO: HHH000206: hibernate.properties not found
lip 10, 2013 10:00:12 AM org.hibernate.cfg.Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist
lip 10, 2013 10:00:12 AM org.hibernate.cfg.Configuration configure
INFO: HHH000043: Configuring from resource: /hibernate.cfg.xml
lip 10, 2013 10:00:12 AM org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: HHH000040: Configuration resource: /hibernate.cfg.xml
lip 10, 2013 10:00:13 AM org.hibernate.internal.util.xml.DTDEntityResolver resolveEntity
WARN: HHH000223: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide!
lip 10, 2013 10:00:13 AM org.hibernate.cfg.Configuration addResource
INFO: HHH000221: Reading mappings from resource: wozek.hbm.xml
lip 10, 2013 10:00:13 AM org.hibernate.internal.util.xml.DTDEntityResolver resolveEntity
WARN: HHH000223: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide!
Exception in thread "main" org.hibernate.InvalidMappingException: Unable to read XML
at org.hibernate.internal.util.xml.MappingReader.readMappingDocument(MappingReader.java:109)
at org.hibernate.cfg.Configuration.add(Configuration.java:488)
at org.hibernate.cfg.Configuration.add(Configuration.java:484)
at org.hibernate.cfg.Configuration.add(Configuration.java:657)
at org.hibernate.cfg.Configuration.addResource(Configuration.java:740)
at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:2167)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:2139)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2119)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2072)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1987)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1966)
at wozki_widlowe.Wozki_widlowe.main(Wozki_widlowe.java:30)
Caused by: org.dom4j.DocumentException: Error on line 27 of document : The element type "hibernate-mapping" must be terminated by the matching end-tag "</hibernate-mapping>". Nested exception: The element type "hibernate-mapping" must be terminated by the matching end-tag "</hibernate-mapping>".
at org.dom4j.io.SAXReader.read(SAXReader.java:482)
at org.hibernate.internal.util.xml.MappingReader.readMappingDocument(MappingReader.java:78)
... 11 more
Java Result: 1
Robiłem wszystko wg poradników i nie potrafię znaleźć gdzie znajduje się błąd dlatego proszę was o pomoc z tym bo siedzę już 2 dzień i kombinuje.