This content has been marked as final.
Show 2 replies
-
1. Re: remove method
sherkan777 Jun 17, 2009 11:41 AM (in response to pmsudha)Hi
1. your question should becan we call remove after persist
?
2. st is equal sto?
3. what is shome and sh using entity manager?please post well formed source code.
-
2. Re: remove method
pmsudha Jun 17, 2009 2:09 PM (in response to pmsudha)Hi this is my code...
"@SuppressWarnings({ "unchecked", "deprecation" })
@Override
public String persist()
{
-------
------
StockDetailHome shome=new StockDetailHome();
StockDetailList u1=new StockDetailList();
StockDetail st=new StockDetail();
String sti=u1.getStockAutoId();
System.out.println("St_Id:"+sti);
st.setStockDetailId(sti);
st.setLocation(to);
st.setReorderQty(5);
st.setQuantity(getInstance().getQty());
ItemDetails ii=new ItemDetails();
ii.setItemCode(itemcode);
st.setItemDetails(ii);
shome.getEntityManager().persist(st);
shome.getEntityManager().flush();
String qu="select stockDetail from StockDetail stockDetail where quantity=0";
List<StockDetail> ls=getEntityManager().createQuery(qu).getResultList();
if(ls.size()!=0)
{
for(int i=0;i<ls.size();i++)
{
System.out.println("Going to delete");
StockDetail sto=new StockDetail();
sto=ls.get(i);
StockDetailHome sh=new StockDetailHome();
sh.getEntityManager().remove(sto);
System.out.println("remove method called");
sh.getEntityManager().flush();
System.out.println("Deleted");
}
}
}
return "persisted";
}"