-->
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.  [ 2 posts ] 
Author Message
 Post subject: session.save problem
PostPosted: Mon Nov 21, 2005 10:28 am 
Newbie

Joined: Mon Nov 21, 2005 9:46 am
Posts: 2
[b]Hi Friends,

I've opened Session Object and i am inserting the values into db without making the session.flush() as following

for(int i=0;i<10;i++){
empDB.setEname("Rama");empDB.setEmpno("123");
session.save(empDB);
}

If this is the case it is inserting first then it is updating the same row.
The 10 records not inserting to DB
if i use session.flush() then only it is accepting to insert.
Wht is the reson any body help me


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 21, 2005 10:50 am 
Newbie

Joined: Wed May 04, 2005 3:33 am
Posts: 6
Hi you will have to create a new Object if you want to insert new objects into the the DB ... This should work:

Code:
for(int i=0;i<10;i++){
empDB = new EmpDB();
empDB.setEname("Rama");empDB.setEmpno("123");
session.save(empDB);
}


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

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.