Hi, i have written one sample application ,and i used MySql database.
when i used the below code ,the data what ever i have given is stored into the table. Transaction tx = session.beginTransaction(); tx.begin(); Book book=new Book(); book.setId(5); book.setBookName("abc"); session.save(book); tx.commit();
but if i use session.saveOrUpdate(book); instead of session.save(book); previous data is deleting and current data only storing into the table.
and one more thing if i want retrive the data from table i used below code for that
Criteria criteria = session.createCriteria(Book.class); System.out.println(criteria.list());
in output ,it is showing as
log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment). log4j:WARN Please initialize the log4j system properly. Hibernate: select this_.id as id0_0_, this_.bookName as bookName0_0_ from book this_ []
it is showing empty in the criteria.list(),
any one help me , i am not getting the problem is from code or MySql .
|