RoleBean.java
/* * 创建日期 2005-1-25 * * 作者:javamxj(分享java快乐) */ package javamxj.ejb.cmp; /** * * <!-- begin-user-doc --> You can insert your documentation for '<em><b>RoleBean</b></em>'. <!-- end-user-doc --> * <!-- begin-lomboz-definition --> <?xml version="1.0" encoding="UTF-8"?> <lomboz:EJB xmlns:j2ee="http://java.sun.com/xml/ns/j2ee" xmlns:lomboz="http://lomboz.objectlearn.com/xml/lomboz"> <lomboz:entity> <lomboz:entityEjb> <j2ee:display-name>Role</j2ee:display-name> <j2ee:ejb-name>Role</j2ee:ejb-name> <j2ee:ejb-class>javamxj.ejb.cmp.RoleBean</j2ee:ejb-class> <j2ee:persistence-type>Container</j2ee:persistence-type> <j2ee:prim-key-class>java.lang.String</j2ee:prim-key-class> <j2ee:cmp-version>2.x</j2ee:cmp-version> <j2ee:abstract-schema-name>RoleSchema</j2ee:abstract-schema-name> <j2ee:primkey-field>name</j2ee:primkey-field> </lomboz:entityEjb> <lomboz:fieldMappings> <lomboz:fieldName>name</lomboz:fieldName> <lomboz:fieldType>java.lang.String</lomboz:fieldType> <lomboz:columnName>权限名称</lomboz:columnName> <lomboz:jdbcType>VARCHAR</lomboz:jdbcType> <lomboz:sqlType>varchar</lomboz:sqlType> <lomboz:readOnly>false</lomboz:readOnly> <lomboz:primaryKey>true</lomboz:primaryKey> </lomboz:fieldMappings> <lomboz:fieldMappings> <lomboz:fieldName>description</lomboz:fieldName> <lomboz:fieldType>java.lang.String</lomboz:fieldType> <lomboz:columnName>权限描述</lomboz:columnName> <lomboz:jdbcType>VARCHAR</lomboz:jdbcType> <lomboz:sqlType>varchar</lomboz:sqlType> <lomboz:readOnly>false</lomboz:readOnly> <lomboz:primaryKey>false</lomboz:primaryKey> </lomboz:fieldMappings> <lomboz:tableName>RoleTable</lomboz:tableName> <lomboz:dataSourceName></lomboz:dataSourceName> </lomboz:entity> </lomboz:EJB> <!-- end-lomboz-definition --> * * <!-- begin-xdoclet-definition --> * @ejb.bean name="Role" * jndi-name="Role" * type="CMP" * primkey-field="name" * schema="RoleSchema" * cmp-version="2.x" * view-type = "local" * data-source="" * * @ejb.persistence * table-name="RoleTable" * * @jboss.persistence * create-table = "true" * remove-table = "false" * * @ejb.finder * query="SELECT OBJECT(a) FROM RoleSchema as a" * signature="java.util.Collection findAll()" * * @ejb.pk class="java.lang.String" * <!-- end-xdoclet-definition --> * @generated **/ public abstract class RoleBean implements javax.ejb.EntityBean { /** * @ejb.create-method */ public java.lang.String ejbCreate(String name, String description) throws javax.ejb.CreateException { // EJB 2.0 spec says return null for CMP ejbCreate methods. setName(name); setDescription(description); return null; } /** * The container invokes this method immediately after it calls ejbCreate. */ public void ejbPostCreate(String name, String description) throws javax.ejb.CreateException { } /** * CMP Field name * @return the name * @ejb.persistent-field * @ejb.persistence * column-name="权限名称" * jdbc-type="VARCHAR" * sql-type="varchar(12)" * read-only="false" * @ejb.pk-field * * @ejb.interface-method */ public abstract java.lang.String getName(); /** * @param java.lang.String the new name value * @ejb.interface-method */ public abstract void setName(java.lang.String name); /** * CMP Field description * @return the description * @ejb.persistent-field * @ejb.persistence * column-name="权限描述" * jdbc-type="VARCHAR" * sql-type="varchar(30)" * read-only="false" * * * @ejb.interface-method */ public abstract java.lang.String getDescription(); /** * @param java.lang.String the new description value * @ejb.interface-method */ public abstract void setDescription(java.lang.String description); } 好了,保存,将 RoleBean 加入到 cmpEJB 模块中,然后 lomboz ->Generate EJB Classes 。 4. 重点:建立 UserBean 对 RoleBean 的多对多的单向联系: · 由于这次设计的是UserBean对RoleBean的单向联系,所以只需要在UserBean中添加方法标记即可。 切换到 UserBean.java ,右击 UserBean ->J2EE ->Add CMR Relationship : · 生成的标记如下,还需要手工添加一些@JBoss标记: · 保存,Generate EJB Classes
本文地址:http://com.8s8s.com/it/it11725.htm