Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
Mapping documents:
Code between sessionFactory.openSession() and session.close():
Full stack trace of any exception that occurs:
Name and version of the database you are using:
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt:
Problems with Session and transaction handling?
Read this:
http://hibernate.org/42.html[code][/code]
public static void main(String args[]) throws SQLException
{
BeanFactory beans=new XmlBeanFactory(new FileSystemResource("applicationContext.xml"));
MyDAO md=(MyDAO)beans.getBean("mydao");
Emp e=new Emp();
e.setEmpno(5);
e.setEname("ch1");
e.setSal(80000);
e.setDeptNO(40);
HibernateTemplate getHibernateTemplate=(HibernateTemplate)beans.getBean("hibernateTemplate");
// Emp e1=(Emp)getHibernateTemplate.get(Emp.class, new Integer(1));
// System.out.println(e1.getEmpno());
getHibernateTemplate.save(e);
getHibernateTemplate.flush();
//
// md.insert(e);
}\
beans default-lazy-init="true">
<bean id="cfg" class="org.hibernate.cfg.Configuration" init-method="configure" />
<bean id="sf" factory-bean="cfg" factory-method="buildSessionFactory"/>
<bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
<constructor-arg>
<ref local="sf"/>
</constructor-arg>
</bean>
<bean id="mydao" class="MyDAO">
<constructor-arg>
<ref local="hibernateTemplate"/>
</constructor-arg>
</bean>
</beans>