Skip to content

Biting the hand that feeds IT

The Register ®

Software:


Related Whitepapers

[Print][Mobile][Alerts]

Migrating EJB 2.1 Entity and Session Beans to EJB 3.0

The nuts and bolts

Page: < Prev 1 2 3 4 5 6 7 Next >
Published Tuesday 25th April 2006 06:02 GMT

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.

Page: < Prev 1 2 3 4 5 6 7 Next >
Track this type of story as a custom Atom/RSS feed or by email.
Previous Article Next Article
whitepaper title

The Register Guides : The status of iSCSI

Now that the hype's abated, have companies backing iSCSI have run out of energy and patience, or is the technology becoming commonplace and accepted?.
whitepaper title

A Green Vision: Interview with VMWare CEO Diane Greene

This interview with VMware CEO Diane Greene discusses how you can realize the financial benefits of energy efficient, greener datacenters through server consolidation..
Whitepapers

The MSDN Developer Zone

Top 20 storiesAll The Week’s HeadlinesArchiveSearch