Joined: Thu Aug 14, 2008 11:03 am Posts: 1 Location: Bangalore
|
Hi..
In my table 1st column is (auto increment) ID, 2nd column is State
how can i get this Id after insert. (below code is working for insert)
from the google i found some methods like
(hibernate.jdbc.use_get_generated_keys )
how can i use this in below code (after session.save(contact))?
plz send me some sample code for this (plz suggest correction in below code to get auto ID)
Thanks in advance.
shrinivas
SessionFactory sessionFactory = new Configuration()
.configure().buildSessionFactory();
session = sessionFactory.openSession();
tx = session.beginTransaction();
Contact contact = new Contact();
contact.setState("Statej");
session.save(contact);
tx.commit();
|
|