back
01 
02 import java.rmi.RemoteException;
03 import javax.ejb.CreateException;
04 import javax.ejb.EntityBean;
05 import javax.ejb.FinderException;
06 import javax.naming.NamingException;
07 
08 /**
09  *
10  * @ejb.bean
11  *         name="${beanname}"
12  *         type="CMP"
13  *         cmp-version="2.x"
14  *      view-type="local"
15  
16  * @ejb.persistence
17  *         table-name="${beanname.toLowerCase()}"
18  
19  * @ejb.finder signature="Collection findAll()"
20  
21  */
22 public abstract class ${beanname}Bean implements EntityBean {
23 
24     // --------------- attributes ---------------------
25 
26     /**
27      *
28      * @ejb.pk-field
29      * @ejb.interface-method
30      * @ejb.persistence
31      */
32     public abstract Long getId();
33 
34     /**
35      * No interface method for setId(..). See page 130 of the EJB 2.0 specification:
36      * "Once the primary key for an entity bean has been set, the Bean Provider must
37      * not attempt to change it by use of set accessor methods on the primary key
38      * cmp-fields. The Bean provider should therefore not expose the set accessor
39      * methods for the primary key cmp-fields in the component interface of the
40      * entity bean.". A work around would be to remove and then an re-create the bean.
41      */
42     public abstract void setId(Long id);
43 
44 #foreach$attributeName in $attribut2type.keySet() )
45     /**
46      *
47      * @ejb.persistence      column-name="${attributeName.toLowerCase()}"
48      * @ejb.interface-method 
49      */
50     public abstract ${attribut2type.get($attributeName)} get${attributeName}();
51 
52     /**
53      * @ejb.interface-method 
54      * @ejb.transaction      type="Required"
55      */
56     public abstract void set${attributeName}(${attribut2type.get($attributeName)} new${attributeName});
57 #end
58 
59     // ---------------- create methods using value object --------------------
60 
61     /**
62      * @ejb.create-method
63      */
64     public ${beanname}PK ejbCreate(${beanname}Value datathrows CreateException {
65 
66 #foreach$attributeName in $attribut2type.keySet() )
67         set${attributeName}( data.get${attributeName}() );
68 #end
69         return null;
70     }
71 
72     // ---------------- get/set for value object --------------------
73 
74     /**
75      * @ejb.interface-method
76      * */
77     public abstract ${beanname}Value get${beanname}Value();
78 
79     /**
80      * @ejb.interface-method
81      * @ejb.transaction type="Required"
82      */
83     public abstract void set${beanname}Value(${beanname}Value new${beanname}Value);
84 
85     // ------------- relations ------------------
86 
87         //TODO: define relations for class ${beanname}Bean
88 
89     // ---------------- business methods --------------------
90 
91         //TODO: implement business methods for class ${beanname}Bean
92 }
Java2html

back