Can't insert record problem,
July 29, 2007 at 8:08 PM
public class FirstExample { public static void main(String[] args) { Session session = null;
try{ // This step will read hibernate.cfg.xml and prepare hibernate for use SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory(); session =sessionFactory.openSession(); org.hibernate.Transaction tx = session.beginTransaction(); //Create new instance of Contact and set values in it by reading them from form object System.out.println("Inserting Record"); Contact contact = new Contact(); contact.setId(6); contact.setFirstName("Deepak"); contact.setLastName("Kumar"); contact.setEmail("deepak_38@yahoo.com"); session.save(contact); tx.commit(); session.flush(); session.close(); System.out.println("Done"); }catch(Exception e){ System.out.println(e.getMessage()); }finally{ // Actual contact insertion will happen at this step }
} }
log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment). log4j:WARN Please initialize the log4j system properly. Inserting Record could not insert: [roseindia.tutorial.hibernate.Contact]
I cannot still insert records but I use exadel to add hibernate capabilities. Please let me know what happen. thanks
View All Comments
| View Tutorial