Hi
I am using EJB 1.1 and BMP Entity Bean. Can I write following code in ejbStore.
public void ejbStore() {
String methodName = "ejbStore";
logger.logMethodBegin(methodName);
DealSheetAssociationInfoHome _home = null;
DealSheetAssociationInfoKey _primaryKey = null;
int _insAgrmntNo = 0;
int _eventNo = 0;
int _objectVerNo = 0;
String _userId =null;
ADMSAssociationChild _associationChild = null;
try{
if(METHOD_FLAG.equals("1")){
return;
}else{
_home = (DealSheetAssociationInfoHome)
myEntityCtx.getEJBHome();
_primaryKey = (DealSheetAssociationInfoKey)
myEntityCtx.getPrimaryKey();
if(_home!=null && _primaryKey!=null){
if(_primaryKey.getModuleName().equals(this.moduleName)){
_insAgrmntNo = this.insAgrmntNo;
_eventNo = this.eventNo;
_objectVerNo = this.objectVerNo;
_userId = this.userId;
_associationChild = this.associationChild;
_home.remove(_primaryKey);
_home.create(_insAgrmntNo,_eventNo,_objectVerNo,_userId,_associationChild);
}
}
}
}catch(CreateException ce){
logger.logFatal(methodName,ce.toString());
throw new javax.ejb.EJBException(ce);
}catch(RemoveException re){
logger.logFatal(methodName,re.toString());
throw new javax.ejb.EJBException(re);
}catch(Exception e){
logger.logFatal(methodName,e.toString());
throw new javax.ejb.EJBException(e);
}finally{
logger.logMethodEnd(methodName);
}
}
-
Calling Home.remove in ejbStore in Entity Bean (3 messages)
- Posted by: vishal jain
- Posted on: December 27 2003 05:29 EST
Threaded Messages (3)
- Calling Home.remove in ejbStore in Entity Bean by Paul Strack on December 27 2003 16:48 EST
- Calling Home.remove in ejbStore in Entity Bean by Hemant Khandelwal on December 29 2003 11:25 EST
- Calling Home.remove in ejbStore in Entity Bean by vishal jain on January 06 2004 07:53 EST
- Calling Home.remove in ejbStore in Entity Bean by Hemant Khandelwal on December 29 2003 11:25 EST
-
Calling Home.remove in ejbStore in Entity Bean[ Go to top ]
- Posted by: Paul Strack
- Posted on: December 27 2003 16:48 EST
- in response to vishal jain
So far as I can tell, this is legal, although it is pretty strange.
Why not just call ejbRemove() directly, rather than indirectly through the Home interface? And ditto for ejbCreate()? That would be more effecient, unless you are doing something strange with transactions. -
Calling Home.remove in ejbStore in Entity Bean[ Go to top ]
- Posted by: Hemant Khandelwal
- Posted on: December 29 2003 11:25 EST
- in response to Paul Strack
Hi Paul,
You are not supposed to call "callbacks" methods directly othewise the conatiner will never come to know of entity creation or removal. If the pupose is only to use SQLs, they are better off in a private methods and used by other methods.
Hemant
www.pramati.com -
Calling Home.remove in ejbStore in Entity Bean[ Go to top ]
- Posted by: vishal jain
- Posted on: January 06 2004 07:53 EST
- in response to Hemant Khandelwal
What is the harm if I go ahead with this approach? Where exactly there will be a trouble?