Ceriwis  

Go Back   Ceriwis > HOBI > Komputer & Teknologi > Programming

Programming Share, tanya jawab, saling bantu antar programmer dengan berbagai macam bahasa pemrograman.

Reply
 
Thread Tools
  #1  
Old 20th November 2011
Linuxmania Linuxmania is offline
Ceriwiser
 
Join Date: Nov 2011
Posts: 392
Rep Power: 14
Linuxmania mempunyai hidup yang Normal
Default Need Help (Java:org.hibernate.StaleObjectStateException)

Langsung aja ya

Jadi begini ceritanya, aku bikin method yang dalam method itu aku punya dua buah List of Object (java.util.List) namanya "updateList" & "saveList"

nah didalam list "updateList" berisi data2 (berupa object dari class CorporateCounterRate) yang mw diupdate ketable (ngupdatenya pake hibernate), data yang mw diupdate ini tentunya dah ada ditable gan, cmn mw diubah doank datanya. Trus list yang satu lagi ("saveList") itu isinya data2 baru (blom ada ditable) yang mw ditambahin ke table. "saveList" juga berisi object dari class CorporateCounterRate. nah pas aku execute tuh method dia bisa jalan sampe bawah (dah ku debug nyampe bawah tapi ga eror) tapi abis selesai jalan semuanya dia kena error gan.

consolenya bilang gini:



Caused by: org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [com.model.CorporateCounterRate#8afa8b813021db2d013 0224c05d100a6]





kira2 kenapa ya gan penyababanya



btw, ini codingan lengkap methodnya gan

mohon bantuannya ya



public void updateCounterRate(Set countRateList, Map map) throws Exception {

Iterator iterator = countRateList.iterator();



countRateList = null;



Corporate corporate = (Corporate) map.get("corporate");

CorporateCounterRatePT countRatePT = (CorporateCounterRatePT) map.get("countRatePT");

CorporateCounterRateDetailPT countRateDetailPT;

CorporateCounterRate countRateSave;

CorporateCounterRate countRateUpdate;



List saveList = new ArrayList();

List updateList = new ArrayList();



java.text.DateFormat sdf = new java.text.SimpleDateFormat("dd MMMM yyyy");

java.util.Date dateNow = new java.util.Date();

sdf.format(dateNow);

java.sql.Timestamp time = new Timestamp(dateNow.getTime());



while(iterator.hasNext()){

countRateDetailPT = (CorporateCounterRateDetailPT) iterator.next();





if(countRateDetailPT.getIdx() != null){

countRateUpdate = new CorporateCounterRate();



countRateUpdate.setPointCounterRate(countRateDetai lPT.getPointCounterRate());

countRateUpdate.setInactive(countRateDetailPT.getI nactive());

countRateUpdate.setValidFrom(countRateDetailPT.get ValidFrom());

countRateUpdate.setValidTo(countRateDetailPT.getVa lidTo());

Currency currency = new Currency();

currency.setCode(countRateDetailPT.getCurrency());

countRateUpdate.setCurrency(currency);

countRateUpdate.setCorporate(corporate);

countRateUpdate.setName(corporate.getName());

countRateUpdate.setId(countRateDetailPT.getIdx());

countRateUpdate.setUpdatedDate(countRatePT.getUpda tedDt());

countRateUpdate.setUpdatedBy(countRatePT.getUpdate dBy());

updateList.add(countRateUpdate);

}else{

countRateSave = new CorporateCounterRate();



countRateSave.setPointCounterRate(countRateDetailP T.getPointCounterRate());

countRateSave.setInactive(countRateDetailPT.getIna ctive());

countRateSave.setValidFrom(countRateDetailPT.getVa lidFrom());

countRateSave.setValidTo(countRateDetailPT.getVali dTo());

Currency currency = new Currency();

currency.setCode(countRateDetailPT.getCurrency());

countRateSave.setCurrency(currency);

countRateSave.setCorporate(corporate);

countRateSave.setName(corporate.getName());

countRateSave.setId(countRateDetailPT.getId());

countRateSave.setCreatedDate(countRatePT.getCreate dDt());

countRateSave.setCreatedBy(countRatePT.getCreatedB y());

saveList.add(countRateSave);

}







}



if(updateList.size() > 0){

try{

this.corporateCounterRateDAO.updateByBatch(updateL ist, updateList.size()+1);

}catch(Exception e){

System.out.println("============================== ============>kena error Pas update");

System.out.println(""+e.getMessage());

e.printStackTrace();

}

}

if(saveList.size() > 0){

try{

this.corporateCounterRateDAO.saveByBatch(saveList, saveList.size()+1);

}catch(Exception e){

System.out.println("============================== ============>Kena error Pas Save");

System.out.println(""+e.getMessage());

e.printStackTrace();

}

}

}




Itu dah ku try catch juga gan, dan di blok catch nya ku sysout, sysoutnya ga keluar diconsole gan, berarti dia ga lewat ke catch kan...

mohon bantuannya ya agan2, tq b4




Reply With Quote
Reply


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


 


All times are GMT +7. The time now is 03:22 PM.


no new posts