Joined: Tue May 10, 2011 8:22 am Posts: 4
|
Hello everyone I am new at Hibernate. I am trying one to many relationship in State and City Table While trying to insert values in a City table with the code void insertCity() { City ct=new City(); Session session=null; ct.setCityName("GANDHINAGAR"); ct.setStateName("GUJRAT"); try{ SessionFactory sessionFactory=new Configuration().configure().buildSessionFactory(); session = sessionFactory.openSession(); } catch(Exception e){ System.out.println("Error"+e); } finally{ session.save(ct); System.out.println("One City Inserted Successfully!!!"); session.flush(); Transaction tx = session.beginTransaction(); tx.commit(); } }
The value of City GANDHINAGAR is inserted but instead of GUJRAT , null is inserted in the City table..... Please give the solution.........
|
|