C M P   2 . 0  
Chapter  
9 
9. CMP 2.0 
Container Managed Persistence by Dain Sundstrom 
Entity Basics 
JBossCMP is a powerful persistence engine compliant with the EJB 2.0 CMP 2.0 
specification.  Although several new features have been added, the basic entity bean 
structure has not changed much in CMP 2.0.  One small, yet very important, change is a 
CMP field is longer declared using a class field in the bean implementation class, but instead 
is declared with a set of abstract accessor methods. Abstract accessors are similar to 
JavaBean property accessors, except no implementation is given. The following listings 
declare the local home, local, and bean implementation class with gangsterId, name, 
nickName, and badness cmp fields: 
// Gangster Local Home Interface  
public interface GangsterHome extends 
EJBLocalHome
 {
   Gangster create(Integer id, String name, String nickName) throws CreateException; 
   Gangster findByPrimaryKey(Integer id) throws FinderException; 
} 
Listing 9 1, Entity Local Home Interface 
// Gangster Local Interface 
public interface Gangster extends 
EJBLocalObject
 {
   Integer getGangsterId(); 
   String getName(); 
   String getNickName(); 
   void setNickName(String nickName); 
} 
Listing 9 2, Entity Local Interface 
// Gangster Implementation Class 
public 
abstract
 class GangsterBean implements EntityBean
 {
   private EntityContext ctx; 
   private Category log = Category.getInstance(getClass()); 
   public Integer ejbCreate(Integer id, String name, String nickName)  
         throws CreateException { 
      log.info("Creating Gangster " + id + "  " + nickName + "  "+ name); 
82






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

best web hosting

 

Our partners: PHP: Hypertext Preprocessor Cheap Web Hosting JSP Web Hosting Ontario Web Hosting  Jsp Web Hosting

Cheapest Web Hosting Java Hosting Cheapest Hosting

Visionwebhosting.net Business web hosting division of Vision Web Hosting Inc.. All rights reserved