Feeds

Migrating EJB 2.1 Entity and Session Beans to EJB 3.0

The nuts and bolts

Providing a secure and efficient Helpdesk

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.

Internet Security Threat Report 2014

More from The Register

next story
UNIX greybeards threaten Debian fork over systemd plan
'Veteran Unix Admins' fear desktop emphasis is betraying open source
Netscape Navigator - the browser that started it all - turns 20
It was 20 years ago today, Marc Andreeesen taught the band to play
Redmond top man Satya Nadella: 'Microsoft LOVES Linux'
Open-source 'love' fairly runneth over at cloud event
Chrome 38's new HTML tag support makes fatties FIT and SKINNIER
First browser to protect networks' bandwith using official spec
Google+ goes TITSUP. But WHO knew? How long? Anyone ... Hello ...
Wobbly Gmail, Contacts, Calendar on the other hand ...
Admins! Never mind POODLE, there're NEW OpenSSL bugs to splat
Four new patches for open-source crypto libraries
prev story

Whitepapers

Forging a new future with identity relationship management
Learn about ForgeRock's next generation IRM platform and how it is designed to empower CEOS's and enterprises to engage with consumers.
Why and how to choose the right cloud vendor
The benefits of cloud-based storage in your processes. Eliminate onsite, disk-based backup and archiving in favor of cloud-based data protection.
Three 1TB solid state scorchers up for grabs
Big SSDs can be expensive but think big and think free because you could be the lucky winner of one of three 1TB Samsung SSD 840 EVO drives that we’re giving away worth over £300 apiece.
Reg Reader Research: SaaS based Email and Office Productivity Tools
Read this Reg reader report which provides advice and guidance for SMBs towards the use of SaaS based email and Office productivity tools.
Security for virtualized datacentres
Legacy security solutions are inefficient due to the architectural differences between physical and virtual environments.