EntityBean (Java EE 5)

Java EE API


javax.ejb Interface EntityBean

All Superinterfaces:
EnterpriseBean, Serializable

public interface EntityBean
extends EnterpriseBean

Implements: EnterpriseBean

EntityBean 接口由每个实体企业 Bean 类实现。容器使用 EntityBean 方法将实例的生命周期事件通知给企业 Bean 实例。
英文文档:

The EntityBean interface is implemented by every entity enterprise Bean class. The container uses the EntityBean methods to notify the enterprise Bean instances of the instance's life cycle events.


Method Summary
 void
 void
 void
 void
 void
 void
 void
 

Method Detail

public void setEntityContext(EntityContext ctx) throws EJBException, java.rmi.RemoteException
设置相关实体上下文。容器在创建实例之后对实例调用此方法。

在未指定的事务上下文中调用此方法。

ctx 实例的 EntityContext 接口。实例应该在实例变量中存储对上下文对象的引用。
ThrowsEJBException: 该方法抛出此异常指示由于系统级错误导致的失败。
Throwsjava.rmi.RemoteException: 此异常在方法签名中定义,以提供对根据 EJB 1.0 规范编写的企业 Bean 的向后兼容。根据 EJB 1.1 规范编写的企业 Bean 应该抛出 javax.ejb.EJBException,而不是此异常。根据 EJB2.0 及更高规范编写的企业 Bean 必须抛出 javax.ejb.EJBException,而不是此异常。

英文文档:

setEntityContext

void setEntityContext(EntityContext ctx)
                      throws EJBException,
                             RemoteException
Set the associated entity context. The container invokes this method on an instance after the instance has been created.

This method is called in an unspecified transaction context.

Parameters:
ctx - An EntityContext interface for the instance. The instance should store the reference to the context in an instance variable.
Throws:
EJBException - Thrown by the method to indicate a failure caused by a system-level error.
RemoteException - This exception is defined in the method signature to provide backward compatibility for enterprise beans written for the EJB 1.0 specification. Enterprise beans written for the EJB 1.1 specification should throw the javax.ejb.EJBException instead of this exception. Enterprise beans written for the EJB2.0 and higher specifications must throw the javax.ejb.EJBException instead of this exception.

public void unsetEntityContext() throws EJBException, java.rmi.RemoteException
取消设置相关实体上下文。容器在移除实例之前调用此方法。

这是容器对实例调用的最后一个方法。Java 垃圾回收器最终将对实例调用 finalize() 方法。

在未指定的事务上下文中调用此方法。

ThrowsEJBException: 该方法抛出此异常指示由于系统级错误导致的失败。
Throwsjava.rmi.RemoteException: 此异常在方法签名中定义,以提供对根据 EJB 1.0 规范编写的企业 Bean 的向后兼容。根据 EJB 1.1 规范编写的企业 Bean 应该抛出 javax.ejb.EJBException,而不是此异常。根据 EJB2.0 及更高规范编写的企业 Bean 必须抛出 javax.ejb.EJBException,而不是此异常。

英文文档:

unsetEntityContext

void unsetEntityContext()
                        throws EJBException,
                               RemoteException
Unset the associated entity context. The container calls this method before removing the instance.

This is the last method that the container invokes on the instance. The Java garbage collector will eventually invoke the finalize() method on the instance.

This method is called in an unspecified transaction context.

Throws:
EJBException - Thrown by the method to indicate a failure caused by a system-level error.
RemoteException - This exception is defined in the method signature to provide backward compatibility for enterprise beans written for the EJB 1.0 specification. Enterprise beans written for the EJB 1.1 specification should throw the javax.ejb.EJBException instead of this exception. Enterprise beans written for the EJB2.0 and higher specifications must throw the javax.ejb.EJBException instead of this exception.

public void ejbRemove() throws RemoveException, EJBException, java.rmi.RemoteException
容器在移除当前与实例关联的 EJB 对象之前调用此方法。当客户端对企业 Bean 的 home 接口或者 EJB 对象的远程接口调用移除操作时调用此方法。此方法将实例从准备状态转移至可用实例池中。

在移除操作的事务上下文中调用此方法。

ThrowsRemoveException: 如果企业 Bean 不允许销毁该对象。
ThrowsEJBException: 该方法抛出此异常指示由于系统级错误导致的失败。
Throwsjava.rmi.RemoteException: 此异常在方法签名中定义,以提供对根据 EJB 1.0 规范编写的企业 Bean 的向后兼容。根据 EJB 1.1 规范编写的企业 Bean 应该抛出 javax.ejb.EJBException,而不是此异常。根据 EJB2.0 及更高规范编写的企业 Bean 必须抛出 javax.ejb.EJBException,而不是此异常。

英文文档:

ejbRemove

void ejbRemove()
               throws RemoveException,
                      EJBException,
                      RemoteException
A container invokes this method before it removes the EJB object that is currently associated with the instance. This method is invoked when a client invokes a remove operation on the enterprise Bean's home interface or the EJB object's remote interface. This method transitions the instance from the ready state to the pool of available instances.

This method is called in the transaction context of the remove operation.

Throws:
RemoveException - The enterprise Bean does not allow destruction of the object.
EJBException - Thrown by the method to indicate a failure caused by a system-level error.
RemoteException - This exception is defined in the method signature to provide backward compatibility for enterprise beans written for the EJB 1.0 specification. Enterprise beans written for the EJB 1.1 specification should throw the javax.ejb.EJBException instead of this exception. Enterprise beans written for the EJB2.0 and higher specifications must throw the javax.ejb.EJBException instead of this exception.

public void ejbActivate() throws EJBException, java.rmi.RemoteException
容器在实例从可用实例池中移出以使其与指定 EJB 对象关联时调用此方法。此方法将实例转换到准备状态。

在未指定的事务上下文中执行此方法。

ThrowsEJBException: 该方法抛出此异常指示由于系统级错误导致的失败。
Throwsjava.rmi.RemoteException: 此异常在方法签名中定义,以提供对根据 EJB 1.0 规范编写的企业 Bean 的向后兼容。根据 EJB 1.1 规范编写的企业 Bean 应该抛出 javax.ejb.EJBException,而不是此异常。根据 EJB2.0 及更高规范编写的企业 Bean 必须抛出 javax.ejb.EJBException,而不是此异常。

英文文档:

ejbActivate

void ejbActivate()
                 throws EJBException,
                        RemoteException
A container invokes this method when the instance is taken out of the pool of available instances to become associated with a specific EJB object. This method transitions the instance to the ready state.

This method executes in an unspecified transaction context.

Throws:
EJBException - Thrown by the method to indicate a failure caused by a system-level error.
RemoteException - This exception is defined in the method signature to provide backward compatibility for enterprise beans written for the EJB 1.0 specification. Enterprise beans written for the EJB 1.1 specification should throw the javax.ejb.EJBException instead of this exception. Enterprise beans written for the EJB2.0 and higher specifications must throw the javax.ejb.EJBException instead of this exception.

public void ejbPassivate() throws EJBException, java.rmi.RemoteException
容器在实例与特定 EJB 对象解除关联之前对实例调用此方法。此方法完成后,容器将实例放置于可用实例池中。

在未指定的事务上下文中执行此方法。

ThrowsEJBException: 该方法抛出此异常指示由于系统级错误导致的失败。
Throwsjava.rmi.RemoteException: 此异常在方法签名中定义,以提供对根据 EJB 1.0 规范编写的企业 Bean 的向后兼容。根据 EJB 1.1 规范编写的企业 Bean 应该抛出 javax.ejb.EJBException,而不是此异常。根据 EJB2.0 及更高规范编写的企业 Bean 必须抛出 javax.ejb.EJBException,而不是此异常。

英文文档:

ejbPassivate

void ejbPassivate()
                  throws EJBException,
                         RemoteException
A container invokes this method on an instance before the instance becomes disassociated with a specific EJB object. After this method completes, the container will place the instance into the pool of available instances.

This method executes in an unspecified transaction context.

Throws:
EJBException - Thrown by the method to indicate a failure caused by a system-level error.
RemoteException - This exception is defined in the method signature to provide backward compatibility for enterprise beans written for the EJB 1.0 specification. Enterprise beans written for the EJB 1.1 specification should throw the javax.ejb.EJBException instead of this exception. Enterprise beans written for the EJB2.0 and higher specifications must throw the javax.ejb.EJBException instead of this exception.

public void ejbLoad() throws EJBException, java.rmi.RemoteException
容器调用此方法指示实例从底层数据库加载状态,以同步其状态。

此方法总是在部署描述符的事务属性值确定的事务上下文中执行。

ThrowsEJBException: 该方法抛出此异常指示由于系统级错误导致的失败。
Throwsjava.rmi.RemoteException: 此异常在方法签名中定义,以提供对根据 EJB 1.0 规范编写的企业 Bean 的向后兼容。根据 EJB 1.1 规范编写的企业 Bean 应该抛出 javax.ejb.EJBException,而不是此异常。根据 EJB2.0 及更高规范编写的企业 Bean 必须抛出 javax.ejb.EJBException,而不是此异常。

英文文档:

ejbLoad

void ejbLoad()
             throws EJBException,
                    RemoteException
A container invokes this method to instruct the instance to synchronize its state by loading it state from the underlying database.

This method always executes in the transaction context determined by the value of the transaction attribute in the deployment descriptor.

Throws:
EJBException - Thrown by the method to indicate a failure caused by a system-level error.
RemoteException - This exception is defined in the method signature to provide backward compatibility for enterprise beans written for the EJB 1.0 specification. Enterprise beans written for the EJB 1.1 specification should throw the javax.ejb.EJBException instead of this exception. Enterprise beans written for the EJB2.0 and higher specifications must throw the javax.ejb.EJBException instead of this exception.

public void ejbStore() throws EJBException, java.rmi.RemoteException
容器调用此方法指示实例通过将其状态存储到底层数据库来使其状态同步。

此方法总是在部署描述符的事务属性值确定的事务上下文中执行。

ThrowsEJBException: 该方法抛出此异常指示由于系统级错误导致的失败。
Throwsjava.rmi.RemoteException: 此异常在方法签名中定义,以提供对根据 EJB 1.0 规范编写的企业 Bean 的向后兼容。根据 EJB 1.1 规范编写的企业 Bean 应该抛出 javax.ejb.EJBException,而不是此异常。根据 EJB2.0 及更高规范编写的企业 Bean 必须抛出 javax.ejb.EJBException,而不是此异常。

英文文档:

ejbStore

void ejbStore()
              throws EJBException,
                     RemoteException
A container invokes this method to instruct the instance to synchronize its state by storing it to the underlying database.

This method always executes in the transaction context determined by the value of the transaction attribute in the deployment descriptor.

Throws:
EJBException - Thrown by the method to indicate a failure caused by a system-level error.
RemoteException - This exception is defined in the method signature to provide backward compatibility for enterprise beans written for the EJB 1.0 specification. Enterprise beans written for the EJB 1.1 specification should throw the javax.ejb.EJBException instead of this exception. Enterprise beans written for the EJB2.0 and higher specifications must throw the javax.ejb.EJBException instead of this exception.


Submit a bug or feature

Copyright 2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.

一看就知道只有菜鸟才干这么无知的事啦。

PS : 未经我党受权你也可自由散发此文档。 如有任何错误请自行修正;若因此而造成任何损失请直接找人民主席,请勿与本人联系。谢谢!