hello, i am trying to make an school project, but i have some problems
i have this class
Code:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package biblioteca.model;
import java.util.HashSet;
import java.util.Set;
/**
*
* @author Alx
*/
public class Abonat {
private int codAbonat;
private String nume;
private int codBiblioteca;
private float penalitati;
private Set<Carte> cartiImprumutate = new HashSet<Carte>(0);
public Abonat(){
}
public int getCodAbonat(){
return codAbonat;
}
public void setCodAbonat(int codAbonat){
this.codAbonat = codAbonat;
}
public String getNume(){
return nume;
}
public void setNume(String nume){
this.nume = nume;
}
public int getCodBiblioteca(){
return codBiblioteca;
}
public void setCodBiblioteca(int codBiblioteca){
this.codBiblioteca = codBiblioteca;
}
public float getPenalitati(){
return penalitati;
}
public void setPenalitati(float penalitati){
this.penalitati = penalitati;
}
public Set<Carte> getCartiImprumutate(){
return cartiImprumutate;
}
public void setCartiImprumutate(Set<Carte> cartiImprumutate){
this.cartiImprumutate = cartiImprumutate;
}
}
this hbm.xml
Code:
<?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>
<class name="Abonat" table="abonat">
<meta attribute="class-description">This class contains abonat details.</meta>
<id name="id" >
<generator class="native" />
</id>
<property name="codAbonat" type="int" not-null="true" column="codAbonat" />
<property name="nume" type="string" length="45" not-null="true" column="nume" />
<property name="codBiblioteca" type="int" not-null="true" column="codBiblioteca" />
<property name="penalitati" type="float" not-null="true" column="penalitati" />
<set name="carti" table="carte_abonat" cascade="all">
<key column="codAbonat" />
<many-to-many column="codCarte" unique="true" class="Carte" />
</set>
</class>
</hibernate-mapping>
and this is the cfg.xml
Code:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory name="sessionFactory">
<property name="hibernate.bytecode.use_reflection_optimizer">false</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.autocommitt">true</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost/test</property>
<property name="connection.username">root</property>
<property name="connection.password">mami</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.current_session_context_class">thread</property>
<mapping resource="biblioteca/model/Abonat.hbm.xml" />
</session-factory>
</hibernate-configuration>
and this are the errors
Code:
run:
log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
Initial SessionFactory creation failed.org.hibernate.InvalidMappingException: Could not parse mapping document from resource biblioteca/model/Abonat.hbm.xml
Exception in thread "main" java.lang.ExceptionInInitializerError
at util.HibernateUtil.<clinit>(HibernateUtil.java:29)
at biblioteca.BibliotecaApp.main(BibliotecaApp.java:49)
Caused by: org.hibernate.InvalidMappingException: Could not parse mapping document from resource biblioteca/model/Abonat.hbm.xml
at org.hibernate.cfg.Configuration.addResource(Configuration.java:602)
at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1621)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1589)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1568)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1542)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1496)
at util.HibernateUtil.<clinit>(HibernateUtil.java:25)
... 1 more
Caused by: org.hibernate.MappingException: class Abonat not found while looking for property: id
at org.hibernate.util.ReflectHelper.reflectedPropertyClass(ReflectHelper.java:97)
at org.hibernate.mapping.SimpleValue.setTypeUsingReflection(SimpleValue.java:302)
at org.hibernate.cfg.HbmBinder.bindSimpleId(HbmBinder.java:423)
at org.hibernate.cfg.HbmBinder.bindRootPersistentClassCommonValues(HbmBinder.java:356)
at org.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:295)
at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:166)
at org.hibernate.cfg.Configuration.add(Configuration.java:702)
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:537)
at org.hibernate.cfg.Configuration.addResource(Configuration.java:599)
... 7 more
Caused by: java.lang.ClassNotFoundException: Abonat
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:123)
at org.hibernate.util.ReflectHelper.reflectedPropertyClass(ReflectHelper.java:93)
... 15 more
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)
could you please help me