WEB开发网
开发学院软件开发Java Apache Geronimo 机器修理店应用示例,第 3 部分:... 阅读

Apache Geronimo 机器修理店应用示例,第 3 部分: EJB:Bean 管理的持久性和容器管理的持久性

 2010-04-16 00:00:00 来源:WEB开发网   
核心提示: publicIntegerejbCreate(SparePartKeykey)throwsCreateException{this.partID=key.partID;this.description=key.description;this.price=key.price;this.horse

  public Integer ejbCreate(SparePartKey key) 
   throws CreateException 
  { 
   this.partID   = key.partID; 
   this.description = key.description; 
   this.price    = key.price; 
   this.horsePower = key.horsePower; 
 
   try 
   { 
     openConnection(); 
     insertRow(); 
     closeConnection(); 
   } // end try 
 
   catch (Exception e) 
   { 
     throw new CreateException("ejbCreate: " + e.getMessage()); 
   } // end catch 
 
   return new Integer(key.partID); 
  } // end ejbCreate 
 
 
  public void ejbPostCreate(SparePartKey key) 
  { 
  } // end ejbPostCreate 
 
 
  public Integer ejbFindByPrimaryKey(Integer primaryKey) 
   throws FinderException 
  { 
   boolean resultFlag; 
 
   try 
   { 
     openConnection(); 
     resultFlag = selectByPrimaryKey(primaryKey); 
     closeConnection(); 
   } // end try 
 
   catch (Exception e) 
   { 
     throw new EJBException("ejbFindByPrimaryKey: " + e.getMessage()); 
   } // end catch 
 
   if (resultFlag) 
   { 
     return primaryKey; 
   } 
   else 
   { 
     throw new ObjectNotFoundException 
      ("Row for id: (" + primaryKey.intValue() + ") not found."); 
   } // end if 
  } // end ejbFindByPrimaryKey 
 
 
  public Collection ejbFindByAll() 
   throws FinderException 
  { 
   Collection result = null; 
 
   try 
   { 
     openConnection(); 
     result = selectAll(); 
     closeConnection(); 
   } // end try 
 
   catch (Exception e) 
   { 
     throw new EJBException("ejbFindByAll: " + e.getMessage()); 
   } // end catch 
 
   if (result.isEmpty()) 
   { 
     throw new ObjectNotFoundException("No rows found."); 
   } 
   else 
   { 
     return result; 
   } // end if 
  } // end ejbFindByAll 

上一页  5 6 7 8 9 10 

Tags:Apache Geronimo 机器

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接