
I have implemented basic hibernate example from your site .
In console i got output but database is not affected.
hbm.xml
<id name="id" type="long" column="id">
<generator class="Assigned" />
</id>
<property name="name" >
<column name="name" />
</property>
<property name="sex" >
<column name="sex" />
</property>
</class>
Main package com.tcs; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.cfg.Configuration; public class Imp { public static void main(String[] args) { Session session = null; try{ SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory(); session =sessionFactory.openSession(); System.out.println("Inserting Record"); Bookdetails book = new Bookdetails();
book.setname("venkat");
book.setid(12102);
book.setsex("male");
session.save(book);
System.out.println("Done");
}catch(Exception e){
System.out.println(e.getMessage());
}
finally{
session.flush();
session.close();
}
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.