Feeds

Migrating EJB 2.1 Entity and Session Beans to EJB 3.0

The nuts and bolts

The essential guide to IT transformation

Listing 7. ejb-jar.xml

<?xml version="1.0"?>
<!DOCTYPE ejb-jar PUBLIC
"-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN"
"http://java.sun.com/dtd/ejb-jar_2_0.dtd">
<ejb-jar>
  <enterprise-beans>
    <entity>
    <ejb-name>Catalog</ejb-name>
    <local-home>CatalogLocalHome</local-home>
    <local>CatalogLocal</local>
    <ejb-class>CatalogBean</ejb-class>
    <persistence-type>Container</persistence-type>
    <prim-key-class>String</prim-key-class>
    <reentrant>False</reentrant>
      <cmp-version>2.x</cmp-version>
      <abstract-schema-name>Catalog</abstract-schema-name>
      <cmp-field>
        <field-name>catalogId</field-name>
      </cmp-field>
      <cmp-field>
        <field-name>journal</field-name>
      </cmp-field>
      <cmp-field>
        <field-name>publisher</field-name>
      </cmp-field>
        <query>
         <query-method>
           <method-name>findByJournal</method-name>
           <method-params>
            <method-param>java.lang.String</method-param>
           </method-params>
         </query-method>
         <ejb-ql>
           <![CDATA[SELECT DISTINCT OBJECT(obj)  FROM Catalog obj WHERE obj.journal = ?1 ]]>
         </ejb-ql>
       </query>
      </entity>
    </enterprise-beans>
    <relationships>

    <ejb-relation>
      <ejb-relation-name>Catalog-Editions</ejb-relation-name>
      <ejb-relationship-role>
        <ejb-relationship-role-name>
          Catalog-Has-Editions
        </ejb-relationship-role-name>
        <multiplicity>One</multiplicity>
        <relationship-role-source>
          <ejb-name>Catalog</ejb-name>
        </relationship-role-source>
        <cmr-field>
          <cmr-field-name>editions</cmr-field-name>
          <cmr-field-type>java.util.Collection</cmr-field-type>
        </cmr-field>
      </ejb-relationship-role>
      <ejb-relationship-role>
        <ejb-relationship-role-name>
          Editions-Belong-To-Catalog
        </ejb-relationship-role-name>
        <multiplicity>One</multiplicity>
        <cascade-delete />
        <relationship-role-source>
          <ejb-name>Edition</ejb-name>
        </relationship-role-source>
      </ejb-relationship-role>
    </ejb-relation>
  </relationships>
</ejb-jar>

An EJB 3.0 entity bean class is a POJO and does not implement the EntityBean interface. In an EJB 3.0 entity bean, the local interface, the local home interface, and the deployment descriptors are not required. Only a bean class annotated with the metadata annotation @Entity is required. The finder methods specified in EJB 2.0 deployment descriptor ejb-jar.xml, with the <query/> elements, are included in the EJB 3.0 bean class with the @NamedQuery annotation. The CMR relationships specified in ejb-jar.xml with <ejb-relation/> elements are included in the EJB 3.0 bean class with metadata annotations. The primary key field in EJB 3.0 is specified with the annotation @Id. Some of the EJB 3.0 metadata annotations are listed in Table 1.

Secure remote control for conventional and virtual desktops

More from The Register

next story
Apple promises to lift Curse of the Drained iPhone 5 Battery
Have you tried turning it off and...? Never mind, here's a replacement
China: You, Microsoft. Office-Windows 'compatibility'. You have 20 days to explain
Told to cough up more details as antitrust probe goes deeper
Linux turns 23 and Linus Torvalds celebrates as only he can
No, not with swearing, but by controlling the release cycle
Scratched PC-dispatch patch patched, hatched in batch rematch
Windows security update fixed after triggering blue screens (and screams) of death
This is how I set about making a fortune with my own startup
Would you leave your well-paid job to chase your dream?
prev story

Whitepapers

Endpoint data privacy in the cloud is easier than you think
Innovations in encryption and storage resolve issues of data privacy and key requirements for companies to look for in a solution.
Implementing global e-invoicing with guaranteed legal certainty
Explaining the role local tax compliance plays in successful supply chain management and e-business and how leading global brands are addressing this.
Advanced data protection for your virtualized environments
Find a natural fit for optimizing protection for the often resource-constrained data protection process found in virtual environments.
Boost IT visibility and business value
How building a great service catalog relieves pressure points and demonstrates the value of IT service management.
Next gen security for virtualised datacentres
Legacy security solutions are inefficient due to the architectural differences between physical and virtual environments.