📄 groupbean.java
字号:
/* * UserEJB - CyberDemia's User management library implemented using EJBs. * Copyright (C) 2004 CyberDemia Research and Services * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. * * See the COPYING file located in the top-level-directory of * the archive of this library for complete text of license. */package com.cyberdemia.user;import java.util.Collection;import javax.ejb.CreateException;import com.cyberdemia.ejb.SimpleEntityBean;/** * GroupBean groups together a set of users so that they can be * manipulated more easily. Groups have many-to-many relationships with users. * This means a user may belong to one or more groups, or no group at all. * * @ejb.bean name="GroupBean" * type="CMP" * view-type="local" * schema="Group" * cmp-version="2.x" * primkey-field="id" * local-jndi-name="ejb/LocalGroup" * * @ejb.util generate="physical" * @ejb.interface local-class="com.cyberdemia.user.LocalGroup" local-extends="javax.ejb.EJBLocalObject" * @ejb.home local-class="com.cyberdemia.user.LocalGroupHome" local-extends="javax.ejb.EJBLocalHome" * @ejb.persistence table-name="UserGroup" * * @jboss.method-attributes pattern="getUsers" read-only="false" * @jboss.method-attributes pattern="get*" read-only="true" * * @ejb.finder signature="java.util.Collection findAll()" * query="SELECT DISTINCT OBJECT(g) FROM Group g" * * @ejb.finder signature="java.util.Collection findByParentId(java.lang.String parentId)" * query="SELECT DISTINCT OBJECT(g) FROM Group g WHERE g.parentId=?1" * * * @jboss.container-configuration name="CyberDemia Optimized Standalone CMP" * * * @author Alexander Yap * @version $Revision: 1.5 $ at $Date: 2004/06/20 10:18:12 $ by $Author: alexycyap $ */public abstract class GroupBean extends SimpleEntityBean{ /** * Gets Collection of all users (LocalUser interfaces) associated with this group. * * @ejb.interface-method * @ejb.relation name="groups-users" role-name="group-has-users" target-ejb="UserBean" target-role-name="user-belongs-to-group" target-multiple="yes" cascade-delete="no" * @jboss.relation fk-constraint="yes" related-pk-field="id" fk-column="userId" * @jboss.relation-table table-name="Group_User" create-table="true" remove-table="false" * * @return Collection of LocalUser interfaces. */ public abstract Collection getUsers(); /** * Sets Collection of all users (LocalUser interfaces) associated with this group. * * @ejb.interface-method * * @param userCol Collection of LocalUser interfaces. */ public abstract void setUsers(Collection userCol); /** * Sets Parent ID of this group. * * @ejb.interface-method * * @param parentId The ID of the parent object.. */ public abstract void setParentId(String parentId); /** * Gets Parent ID of this group. * * @ejb.interface-method * @ejb.persistence * * @return Parent ID of this group. */ public abstract String getParentId(); //----------------------------- // Create methods. //----------------------------- /** * Creates a GroupBean. * * @ejb.create-method view-type="local" */ public Integer ejbCreate(String name, String parentId) throws CreateException { // Note : Unique ID is assigned by database auto-increment setName(name); setParentId(parentId); long nowMillis = System.currentTimeMillis(); setCreatedMillis( nowMillis ); return null; } public void ejbPostCreate(String name, String parentId) { // Nothing here } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -