After adding the to the db (commiting the data), not getting the latest inserted data in my AccessBean. But when I come backto the jsp again the data is available. I don't know how to resolve the issue.
Below is the insert code in cmdImpl
AddressAccessBean add = new AddressAccessBean(Long.parseLong(memberid),shipid);
shipBean.setInitKey_ShipToCodeName(shipid);
add.setAddressField2(shipBean.getName()+shipBean.getCity()+shipBean.getState());
add.setAddressField1("WD");
add.setMemberId(memberid);
add.setAddressField3(shipid);
add.setStatus("P");
add.commitCopyHelper();
After commiting the data.trying to fetch data on jsp through accessbeans and their finder methods and displaying into table in jsp
<%
String[] member_Id = (String[])request.getAttribute("memberid");
String memberId=member_Id[0];
AddressAccessBean add = new AddressAccessBean();
java.util.Enumeration enu = add.findByMemberId(Long.parseLong(memberId));
while (enu.hasMoreElements()) {
AddressAccessBean as = (AddressAccessBean) enu.nextElement();
if (as.getAddressField3() != null && as.getAddressField1().equals("WD")) {
com.ibm.commerce.extension.objects.xShipToCodeAccessBean bb = new com.ibm.commerce.extension.objects.xShipToCodeAccessBean().findByShipToCodeName(as.getAddressField3());
%>
<TR>
<Td ALIGN="LEFT" width="20%"><%=as.getAddressField2()%></Td>
<Td ALIGN="LEFT" width="20%"><%=bb.getName()%></Td>
<Td ALIGN="LEFT" size="15%"><%=bb.getShipToCodeName()%></Td>
<Td ALIGN="LEFT" size="10%"><%=bb.getCity()%></Td>
<Td ALIGN="LEFT" size="10%"><%=bb.getState()%></Td>
<Td ALIGN="LEFT" size="10%"><%=bb.getSoldTo()%>
</Td>
If you are fowarding to the JSP, data inserted through entity/access beans will not be visible to a finder query. i.e., if you are forwarding to a JSP instead of a redirect, transaction gets committed only after the execution of JSP. Entity bean changes are written to db after transaction is committed. Thats is why you are not able to see the insert while trying to use a finder query.
You have two options :-