we are using mvc-2 architecture.when i want to modify the employee details what
we r doing is from controller it will goes to modifyEmployee method in
sessionbean.as u can see in code we will setEmployeeMaster inturn it will call
setEmployeeMaster in Entity bean ;we r using EJB1.1;
i am checking whether sizes of empcharges and deptcharges does not equal then
throw exception and total transaction should be rollback.
At the time of reterving the count of two tables even data is not inserted in
two tables in ejbStore() because ejbStore will be called by the container;after
executing full modifyEmployee() method only container is calling ejbStore where
i am inserting data in two tables;
my requirment is i have to check whether in two tables any mismatch is going ;
how can i write this in this type of scenario?but while creating employee
details i have put same condition where ejbCreate will be called at that time
transaction is rolledback.(when i say home =
(EmployeeEntityHome)ictx.lookup("EmployeeEntityBean");
remote = (EmployeeEntity)home.create(); container is calling immediately
ejbCreate);
but in this case container is not calling immediately ejbStore when i say
remote.setEmployeeMaster(employeeMaster);
i have written Pseudo code may be some errors are there;i am using JBoss
Session bean
**********
modifyEmployee(EmpMaster empMaster) thrpws MismatchException
{
try
{
*************other business processes******************
ictx = new InitialContext();
home = (EmployeeEntityHome)ictx.lookup("EmployeeEntityBean");
remote = (EmployeeEntity)home.findByPrimaryKey(new Long(empMaster.empNo));
remote.setEmployeeMaster(employeeMaster);
*************other business processes******************
query1="select count(*) from empcharges where empno='*****'"
query2="select count(*) from deptcharges where deptpno='*****'"
rs=stmt.executeQuery(query1);
rs1=stmt.executeQuery(query2);
if(rs.next)
int cnt1=rs.getInt(1);
if(rs1.next)
int cnt2=rs.getInt(1);
if(cnt1 != cnt2)
{
flag =true;
}
if(flag)
throw new MismatchException("mismatch exception ");
}
catch(Exception e)
{
ctx.rollBackOnly();
}
}
EntityBean
***********
public void setEmployeeMaster(EmployeeMasterDOB employeeMasterDOB)
{
this.employeeMasterDOB = employeeMasterDOB;
isDirty = true;
}
public void ejbStore() throws javax.ejb.EJBException
{
try
{
if(isDirty)
{
isDirty = false;
EmployeeMaster EmployeeMasterDAO = new EmployeeMaster();
EmployeeMasterDAO.store(employeeMasterDOB);
}
}
catch(Exception ex)
{
throw new EJBException(ex.getMessage());
}
}
EmployeeMasterDAO
****************
store(employeeMasterDOB)
{
data will be inserted in empcharges and deptcharges tables...
}
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3943140#3943140
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3943140
-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user