hi
table is simple table which have only 3 fields. id,name,dob.
this is the save file for saving database.
protected ModelAndView onSubmit(Object command)
{
//Get the Object from request
Employee emp=(Employee)command;
try {
Session sess = null;
// DefaultTransactionStatus def= new DefaultTransactionStatus();
SessionFactory sf = trMgr.getSessionFactory();
//Open Session for database communication
sess = sf.openSession();
sess.save(emp);
}catch (HibernateException e) {
e.printStackTrace();
}
return new ModelAndView("index");
}
}
This is the mapping file
PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping package="mobera.application.business">
<class name="Employee" table="TBL_EMP_PRO">
<id name="empid" type="integer" unsaved-value="null" >
<column name="emp_id" sql-type="int" not-null="false"/>
<generator class="increment"/>
</id>
<property name="empname">
<column name="emp_name" length="20" not-null="false"/>
</property>
<property name="empdob">
<column name="emp_dob" length="10" not-null="false"/>
</property>
</class>
</hibernate-mapping>
do u require any more information.
Thanks and regards
Ajay
|