Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

Anchor
top
top
Image Removed
Article donated by: Leonard Flournoy, Hernan Cunico

Overview


An entity bean is defined as a representation of persistent data that has the ability to read from database and populate its fields with data. It can be updated and stored back to the database. There are two types of entity beans: Bean-Managed Persistence(BMP) and Container-Managed Persistent(CMP). This article covers an example of a CMP, more specifically, a CMP application migration. For this type of entity bean, actual code must be written to handle persistent operations such as loading, saving and finding data. The developer must use persistence API such as JDBC to select, insert, update, delete from a database.

...

CREATE TABLE CUSTOMER(ID INTEGER NOT NULL PRIMARY KEY,NAME VARCHAR(45),BIRTHDATE DATE,SSS_NO VARCHAR(25),ADDRESS VARCHAR(60),ANNUAL_SALARY DOUBLE,LOAN_AMOUNT DOUBLE)

Back to Top

Configure Maven

You should set the maven.geronimo.home property in project.properties to point to your <geronimo_home> directory.

Back to Top

Step-by-step migration
Anchor
migration
migration

...

Code Block
xml
xml
borderStylesolid
titlecustomer-ejb.xml
<?xml version="1.0" encoding="UTF-8"?>

<openejb-jar
    xmlns="http://www.openejb.org/xml/ns/openejb-jar"
    xmlns:naming="http://geronimo.apache.org/xml/ns/naming"
    xmlns:security="http://geronimo.apache.org/xml/ns/security"
    xmlns:sys="http://geronimo.apache.org/xml/ns/deployment"
    configId="CustomerEJB"
    parentId="orggeronimo/apache/geronimo/SystemDatabasesystem-database/1.0/car">
<enterprise-beans>
    <entity>
        <ejb-name>CustomerEJB</ejb-name>
        <jndi-name>CustomerHomeRemote</jndi-name>
        <local-jndi-name>CustomerRemote</local-jndi-name>
        <resource-ref>
            <ref-name>jdbc/ibm-demo</ref-name>
            <resource-link>SystemDatasource</resource-link>
        </resource-ref>
    </entity>
</enterprise-beans>
</openejb-jar>

This plan sets orggeronimo/apache/geronimo/SystemDatabasesystem-database/1.0/car as the parent. What follows is the definition of the entity bean. The jndi-name element indicates the jndi name of the entity bean's home interface CustomerHomeRemote. This is the name that the Loan CMP sample application will lookup in the jndi context. The element local-jndi-name indicates the jndi name of the local interface, which in this case happens to be a remote interface, CustomerRemote. Next, a reference to the SystemDatasource is defined giving the application access to the database.

...