ENTITY BEAN IN JAVA
                           Hiren Jamod
         Department Of ComputerScience
             Saurastra University-Rajkot
ENTITY BEANS
 Enterprise Beans which represent persistent
  data stored in a storage medium, such as a
  relational database.
 Persists across multiple sessions and can be
  accessed by multiple clients.
 Each instance of the entity bean represent a row
  in the table
 EJB container creates instances of an entity bean
  and is responsible for loading data in an instance
  and storing the information (data) back into the
  database.
ENTITY BEANS
   The persistent mechanisms that enable you to
    perform these database manipulations, such as
    serialization, Object/Relationship (O/R) mapping
    to a relational database and support for JDBC
    are built-in the entity bean model
CHARACTERISTICS
                         Persistence
   Implies that its state exists even after a client stops
    accessing an application
   The persistent data remain intact even after the
    storage shuts down
                       Shared Access
   Multiple clients can share one entity bean by using
    separate instances of the entity bean
   EJB Container maintains data consistency by
    synchronizing entity bean instances with the
    database
   To maintain data consistency, the entity beans work
    within a transaction
CHARACTERISTICS
                   Primary Key
 Each Entity bean has unique identifier; is known
  as Primary Key that enables the client to locate
  the exact entity bean
                   Relationships
 Like the data of a relational database, the entity
  beans are also elated to each other
LIFE CYCLE OF ENTITY BEANS
LIFE CYCLE OF ENTITY BEANS
 Initially, the beans do not exist
 When the Application server this stage to the Pooled
  stage
 When the server is first started, several bean
  instances are created and placed in the pool.
 A bean instance in the pooled state is not ties to

   particular data
 At this stage, the beans are referred as passivated.

 The bean remains in this stage till the client does

  not make a request for it or the container does not
  activate it.
LIFE CYCLE OF ENTITY BEANS
 The bean’s business methods can be invoked
  when the bean is at the ready stage.
 It remains at this stage till the client calls its
  remove method or the container passiveness it if
  the bean has been lying idle for sometimes
EJB SOURCE CODE
   Home Interface (extends EJBHome)
     Create - Find (for Entity)
     Factory Pattern
   Remote Interface (EJBObject)
     “Business Methods”
     Proxy Pattern
 Bean Class (EntityBean)
 Deployment descriptor (ejb-jar.xml)
CRAETE APPLICATION
GIVE NAME OF CRAETE APPLICATION
ADD SESSION BEAN
GIVE NAME OF SESSION BEAN
ADD PERSISTENCE UNIT
GIVE NAME PERSISTENCE UNIT
ADD ENTITY CLASS
ADD REFERENCE INTO WEB.XML
DECLER INTERFACE
DEFINE INTERFACE AND OVERRIDE
METHOD
DEFINE ENTITY BEANCLASS
DEFINE INDEX PAGE
DEFINE INDEX PAGE
DEFINE INDEX PAGE
DEFINE INDEX PAGE
SPECIAL THANKS T0 AMIT SIR
TO GIVE ME OPPORTUNITY TO REPRESENT MY
PRESENTATION.
                         BY HIREN JAMOD

Entity beans in java

  • 1.
    ENTITY BEAN INJAVA Hiren Jamod Department Of ComputerScience Saurastra University-Rajkot
  • 2.
    ENTITY BEANS  EnterpriseBeans which represent persistent data stored in a storage medium, such as a relational database.  Persists across multiple sessions and can be accessed by multiple clients.  Each instance of the entity bean represent a row in the table  EJB container creates instances of an entity bean and is responsible for loading data in an instance and storing the information (data) back into the database.
  • 3.
    ENTITY BEANS  The persistent mechanisms that enable you to perform these database manipulations, such as serialization, Object/Relationship (O/R) mapping to a relational database and support for JDBC are built-in the entity bean model
  • 4.
    CHARACTERISTICS Persistence  Implies that its state exists even after a client stops accessing an application  The persistent data remain intact even after the storage shuts down Shared Access  Multiple clients can share one entity bean by using separate instances of the entity bean  EJB Container maintains data consistency by synchronizing entity bean instances with the database  To maintain data consistency, the entity beans work within a transaction
  • 5.
    CHARACTERISTICS Primary Key  Each Entity bean has unique identifier; is known as Primary Key that enables the client to locate the exact entity bean Relationships  Like the data of a relational database, the entity beans are also elated to each other
  • 6.
    LIFE CYCLE OFENTITY BEANS
  • 7.
    LIFE CYCLE OFENTITY BEANS  Initially, the beans do not exist  When the Application server this stage to the Pooled stage  When the server is first started, several bean instances are created and placed in the pool.  A bean instance in the pooled state is not ties to particular data  At this stage, the beans are referred as passivated.  The bean remains in this stage till the client does not make a request for it or the container does not activate it.
  • 8.
    LIFE CYCLE OFENTITY BEANS  The bean’s business methods can be invoked when the bean is at the ready stage.  It remains at this stage till the client calls its remove method or the container passiveness it if the bean has been lying idle for sometimes
  • 9.
    EJB SOURCE CODE  Home Interface (extends EJBHome)  Create - Find (for Entity)  Factory Pattern  Remote Interface (EJBObject)  “Business Methods”  Proxy Pattern  Bean Class (EntityBean)  Deployment descriptor (ejb-jar.xml)
  • 10.
  • 11.
    GIVE NAME OFCRAETE APPLICATION
  • 12.
  • 13.
    GIVE NAME OFSESSION BEAN
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
    DEFINE INTERFACE ANDOVERRIDE METHOD
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
    SPECIAL THANKS T0AMIT SIR TO GIVE ME OPPORTUNITY TO REPRESENT MY PRESENTATION. BY HIREN JAMOD