-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Hibernate with mysql
PostPosted: Sat Jul 25, 2009 1:54 pm 
Newbie

Joined: Sat Jul 25, 2009 1:28 pm
Posts: 1
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 .


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.