⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 simpleentitybean.java

📁 老外的在线考试
💻 JAVA
字号:
/* * Core - Library of useful classes that are used in many CyberDemia projects. * 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.ejb;/** * SimpleEntityBean is an abstract base class for a majority of entity EJBs that * require some common fields such as id and name. * It has a primary key field named "id" of type Integer that is meant to * be auto-incremented by the app server/database. Hence the method * <code>getGeneratedPrimaryKey()</code> is provided to retrieve the * auto-generated key immediately after creating the bean. * * @ejb.bean name="SimpleEntityBean" *           generate="false" *           type="CMP" *           view-type="local" * * @ejb.pk class="java.lang.Integer" * @jboss.unknown-pk class="java.lang.Integer" auto-increment="true" jdbc-type="INTEGER" sql-type="INTEGER" * @jboss.entity-command name="mysql-get-generated-keys" * * @author Alexander Yap * @version $Revision: 1.1 $ at $Date: 2004/06/20 10:17:20 $ by $Author: alexycyap $ */public abstract class SimpleEntityBean extends BaseEntityBean{	/**	* Gets the unique Id for this entity.	*	* @ejb.persistence read-only="true"	* @ejb.pk-field	* @ejb.interface-method	* @jboss.persistence auto-increment="true"	*	* @return Unique Id	*/	public abstract Integer getId();	/**	* Sets the unique Id for this entity.	* This method is never used.	* @param id Unique Id	*/	public abstract void setId(Integer id);	/**	* Gets the display name for this entity.	*	* @ejb.interface-method	* @ejb.persistence	* @jboss.persistence not-null="true" dbindex="true"	*	* @return Display name	*/	public abstract String getName();	/**	* Sets the display name lookup key for this entity.	*	* @ejb.interface-method	*	* @param name Display name	*/	public abstract void setName(String name);	/**	* Gets the creation datetime of the entity in milliseconds.	* This field is purely to track when this entity was created,	* and should be set in ejbCreate.	*	* @ejb.interface-method	* @ejb.persistence	*	* @return Create date	*/	public abstract long getCreatedMillis();	/**	* Sets the creation datetime of the entity in milliseconds.	* This field is purely to track when this entity was created,	* and should be set in ejbCreate.	* @param created Creation datetime in milliseconds	*/	public abstract void setCreatedMillis(long created);	/**	* Gets the auto-generated primary key (field "id").	* Useful to retrieve the primary key immediately after	* creating the bean, when <code>getId()</code> would return null.	* This method will convert the primary key to an Integer,	* which is the type of the "id" field.	*	* @ejb.interface-method	*	* @return Primary key	*/	public Integer getGeneratedPrimaryKey()	{		Object pk = getEntityContext().getPrimaryKey();		if (pk instanceof Integer)		{			return (Integer)pk;		}		if (pk instanceof Number)		{			return new Integer(((Number)pk).intValue());		}		return new Integer( pk.toString() );	}} 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -