ReCom.org
Portal Page Forum Wiki Social Groups Scholarship Holders Infobase Site Map About
Go Back   ReCom.org > Forum > ReCom Activities Hub > ReCom Computer Lab > Programming and Web Development

Programming and Web Development Web monks and programmers welcomed

Problem in simultaneous insert in same table using JPA

Reply
 
Thread Tools
suvsuv Male
Super Junior Member
 
Join Date: Sep 2010
Posts: 1
  #1 Old 15-09-2010 Question Problem in simultaneous insert in same table using JPA

Description: Here is a for loop. that means if 'for loop' is running 5 times - there will be 5 times insert/update in a same table. Parameters of the function are array of string.
But i bring 3 sets of data in array of string - that means for loop will run 3 times - and it should 'insert' 3 times in same table simultaneously. but interestingly it is inserting just for first time and ignoring others. But i have checked that value is changing for every time.


public String updateInsertInv(int productNo, int timekey, String caller_pid[], String caller_amt[], String callerUpIn[])
throws ClassNotFoundException, SQLException
{
EntityTransaction et = em.getTransaction();
try {
et.begin();
int len = productNo;
int b=0;
// Daily_inventory c[] = new Daily_inventory[100];
Daily_inventory c = new Daily_inventory();

int tkey = 0, productID = 0 , k =0;
float begin_inv = 0, purchase_amt=0, end_inv=0,the_amt=0,waste =0,missing=0;
String tt = "suv";
for(int a=0; a<len;a++)
{
tkey = timekey;
productID = Integer.parseInt(caller_pid[b]);
the_amt = Integer.parseInt(caller_amt[b]);

if(callerUpIn[b].equals("update"))
{
//update
}
else if(callerUpIn[b].equals("insert"))
{
//insert
c.setTime_id(tkey);
c.setProduct_id(productID);
c.setBegin_inv(begin_inv);
c.setPurchase(purchase_amt);
c.setEnd_inv(end_inv);
c.setTheoratical_amt(the_amt);
c.setWaste(waste);
c.setMissing(missing);

em.persist(c);
}

tt = tt + tkey + productID + the_amt + callerUpIn[b]+" ";
}
b=b+1;
}
et.commit();
return tt;
}
catch (Exception e) {
e.printStackTrace();
return e.getMessage();
}

}
suvsuv is offline   Reply With Quote
Leen
Peacemaker
Administrator
 
Leen's Avatar
 
Join Date: Feb 2006
Posts: 651
  #2 Old 17-09-2010 Default Re: Problem in simultaneous insert in same table using JPA

Wrong place to ask again. Redirecting...
Leen is offline   Reply With Quote
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Table-tennis fan? taufiq ReCom Sports Bar 16 15-12-2010 06:58 PM
SPM/STPM Time Table 2008 Download joshuatly SPM & STPM 9 02-12-2008 11:24 AM
Problem with DDR ram kelvinlym Hardware and Software Issues 9 06-01-2004 02:07 PM


All times are GMT +8. The time now is 07:23 AM.


Powered by vBulletin® Version 3.7.6
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

ReCom stands for Reborn Community. It has no affiliation with other organizations that may share the same name. The views expressed in this website solely represent the authors point of view and do not necessarily reflect the views of ReCom Anchors and other ReCom users.


 

Page generated in 0.08391 seconds with 16 queries