Register | Login
Home
Add Question
Add Article
Categories
Latest Articles
Tags
Contact Us
Search:
Search questions and share your knowledge with the world here on Questionpoint.
Home
>
EJB Interview Questions and Answers
>
What are the methods of Entity Bean?
:: Categories ::
Java
Behavioral
HR
management
Sales
C#.Net
J2EE
Teaching
Struts
Marketing
Finance
Sharepoint
Accounting
JSP
General
Servlet
LINQ
Asp.net 2.0
Asp.net 1.1
Asp.net 3.5
Sql Server 2005
sql server 2008
Sql Server 2000
Microsoft CRM
Visual Studio 2008
Visual Studio 2005
Visual Studio 2003
SilverLight
Internet Information Server
J2ME
Hibernate
JBoss
J2SE
Groovy
Vb.Net
USA Immigration
Tricky
Oracle
SAP
PHP
Linux
Resume Writing
Resume Samples
Interview Tips
Other
Asp.Net 4.0
Software Sales
Call Center
BizTalk 2006
Network Support
Help Desk Support
EJB
JDBC
Spring
JSF
Ajax
Javascript
Interview Question in EJB
Interview Question :: What are the methods of Entity Bean?
What are the methods of Entity Bean?
by
ksk
Entity Beans
Entity Bean methods
Bean create methods
Bean finder methods
Bean remove methods
Bean home methods
VoteNow
Answers to "What are the methods of Entity Bean?"
An entity bean consists of 4 groups of methods:
1. create methods: To create a new instance of a CMP entity bean, and therefore insert data into the database, the create() method on the bean's home interface must be invoked. They look like this: EntityBeanClass ejbCreateXXX(parameters), where EntityBeanClass is an Entity Bean you are trying to instantiate, ejbCreateXXX(parameters) methods are used for creating Entity Bean instances according to the parameters specified and to some programmer-defined conditions.
A bean's home interface may declare zero or more create() methods, each of which must have corresponding ejbCreate() and ejbPostCreate() methods in the bean class. These creation methods are linked at run time, so that when a create() method is invoked on the home interface, the container delegates the invocation to the corresponding ejbCreate() and ejbPostCreate() methods on the bean class.
2. finder methods: The methods in the home interface that begin with "find" are called the find methods. These are used to query the EJB server for specific entity beans, based on the name of the method and arguments passed. Unfortunately, there is no standard query language defined for find methods, so each vendor will implement the find method differently. In CMP entity beans, the find methods are not implemented with matching methods in the bean class; containers implement them when the bean is deployed in a vendor specific manner. The deployer will use vendor specific tools to tell the container how a particular find method should behave. Some vendors will use object-relational mapping tools to define the behavior of a find method while others will simply require the deployer to enter the appropriate SQL command.
There are two basic kinds of find methods: single-entity and multi-entity. Single-entity find methods return a remote reference to the one specific entity bean that matches the find request. If no entity beans are found, the method throws an ObjectNotFoundException . Every entity bean must define the single-entity find method with the method name findByPrimaryKey(), which takes the bean's primary key type as an argument.
The multi-entity find methods return a collection ( Enumeration or Collection type) of entities that match the find request. If no entities are found, the multi-entity find returns an empty collection.
3. remove methods: These methods (you may have up to 2 remove methods, or don't have them at all) allow the client to physically remove Entity beans by specifying either Handle or a Primary Key for the Entity Bean.
4. home methods: These methods are designed and implemented by a developer, and EJB specification doesn't have any requirements for them except the need to throw a RemoteException is each home method.
by
ksk
Loading ...
Login Here
Sign Up Here
Username
*
Password
*
Username
*
Fullname
*
Password
*
Confirmpassword
*
Email
*
Login Here
Sign Up Here
Username
*
Password
*
Username
*
Fullname
*
Password
*
Confirmpassword
*
Email
*