This question seems to be repeated but i tried all possibilities i could do but not able to resolve this error. please help me i am beginner in Hibernate.
-FirstProject
--->src
------>myPackage
--> Employee.java
--> StoreData.java
--->Employee.hbl.xml
--->hibernate.cfg.xml
Both xml files are under src folder and here my code goes
package mypackage;
**public class Employee**
{
private int id;
private String FirstName,LastName;
public int getId()
{
return id;
}
public void setId(int id)
{
this.id=id;
}
public String getFirstName()
{
return FirstName;
}
public void setFirstName(String FirstName)
{
this.FirstName=FirstName;
}
public String getLastName()
{
return LastName;
}
public void setLastName(String LastName)
{
this.LastName=LastName;
}
}
Employee.hbl.xml
<class name="mypackage.Employee" table="emp1000">
<id name="id">
<generator class="assigned"></generator>
</id>
<property name="firstName" column="fname" type="String"></property>
<property name="lastName" column="lname" type="String"></property>
</class>
hibernate.cfg.xml
<session-factory>
<property name="hbm2ddl.auto">update</property>
<property name="dialect">org.hibernate.dialect.Oracle9Dialect</property>
<property name="connection.url">jdbc:oracle:thin:@localhost:1521:xe</property>
<property name="connection.username">system</property>
<property name="connection.password">12345</property>
<property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<mapping resource="First/src/Employee.hbm.xml"/>
</session-factory>
StoreData.java
package mypackage;
public class StoreData {
public static void main(String[] args) {
SessionFactory sF = new Configuration().
configure("/First/src/mypackage/hibernate.cfg.xml").buildSessionFactory();
Session session=sF.openSession();
Transaction t=session.beginTransaction();
Employee e1=new Employee();
e1.setId(115);
e1.setFirstName("Madu");
e1.setLastName("biradar");
session.persist(e1);
t.commit();
session.close();
System.out.println("successfully saved");
}
}
Thanks to all who would give any sort of suggestion...
Employee.hbl.xmlis a typo, you have mapped with namehbm, and file name ishbl, maybe just a type and is no related the eaxt issue, also post the complete stacktrace