User: vharcq  
  Date: 01/06/24 14:39:03

  Modified:    src/docs customizingjaws.xml
  Log:
  Added chapter/example on Dependant Value Object
  
  Revision  Changes    Path
  1.12      +80 -0     manual/src/docs/customizingjaws.xml
  
  Index: customizingjaws.xml
  ===================================================================
  RCS file: /cvsroot/jboss/manual/src/docs/customizingjaws.xml,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- customizingjaws.xml       2001/06/24 09:59:00     1.11
  +++ customizingjaws.xml       2001/06/24 21:39:03     1.12
  @@ -615,4 +615,84 @@
   find you have to modify it, please consider sharing your changes:
   post the modified mapping on the jbosscmp mailing list.</para>
      </section>
  +   <section>
  +      <title>Dependant Value Objects [since JBoss 2.4]</title>
  +         <para>Author: 
  +            <author>
  +               <firstname>Vincent</firstname>
  +               <surname>Harcq</surname>
  +            </author>
  +            <email>[EMAIL PROTECTED]</email>
  +         </para>
  +       <para>Standards compliance note: this feature is not standard or required in 
EJB 1.1. Therefore, EJBs that 
  +use this feature, might not be compile-free portable to other EJB containers.</para>
  +      <para>JAWS store non primitive type fields as Object in the database.  When 
the field is a JavaBean, an object with 
  +      some primitive type attributes with getter/setter accessing methods, it is 
possible to store the value of these attributes
  +instead of the whole object.</para>
  +<para>For example suppose in the Class bean, we have a field "lesson" representing 
the subject (english, mathematics,..)
  +and the number of hours that the teacher take to give its lesson.  This field is an 
simple JavaBean:</para>
  +<programlisting><![CDATA[
  +package org.jboss.docs.cmp.jaws.interfaces;
  +
  +import java.io.Serializable;
  +
  +public class LessonDetail
  +implements Serializable{
  +
  +   private String subject;
  +   private Integer hours;
  +
  +   public String getSubject(){ return subject; }
  +   public void setSubject(String subject){ this.subject = subject; }
  +
  +   public Integer getHours(){ return hours; }
  +   public void setHours(Integer hours){ this.hours = hours; }
  +
  +}
  +]]></programlisting>
  +<para>The ejb-jar.xml will still define "lesson" as the CMP field:</para>
  +<programlisting><![CDATA[
  +<ejb-jar>
  +  <display-name>Class</display-name>
  +  <enterprise-beans>
  +    <entity>
  +      ...
  +       <cmp-field><field-name>lesson</field-name></cmp-field>
  +       ...
  +    </entity>
  +  </enterprise-beans>
  +</ejb-jar>
  +
  +]]></programlisting>
  +<para>But jaws.xml will say how to store/retrieve
  +the object:</para>
  +<programlisting><![CDATA[
  +<jaws>
  +     <enterprise-beans>
  +             <entity>
  +                     ...
  +                     <cmp-field>
  +                             <field-name>lesson.subject</field-name>
  +                             <column-name>LESSON_SUBJECT</column-name>
  +                     </cmp-field>
  +                     <cmp-field>
  +                             <field-name>lesson.hours</field-name>
  +                             <column-name>HOURS</column-name>
  +                     </cmp-field>
  +                     ...
  +             </entity>
  +     </enterprise-beans>
  +</jaws>
  +]]></programlisting>
  +<para>Two database fields are now used to store the "value" of the object.  The 
trick is to have getter/setter method
  +corresponding to what you have to store/retrieve.</para>
  +<para>This feature is recursive, so you can have something like 
lesson.subject.name, lesson.subject.group,...</para>
  +<para>Notice that if the dependant object defines its attributes as "public", the 
getter/setter methods are not necessary.
  +This can be used in an entity bean to store a reference to another entity bean by 
its Primary Key object.  Indeed, in
  +this case, the primary key fields are declared as public in the PK class.</para>
  +<para>Finally notice that even if this a non standard requirement in EJB 1.1, there 
is a way to program this in a standard way.
  +This is to define the 2 CMP fields in the bean and access them through 
getter/setter method of "LessonDetail" type.
  +These will map the database fields to the object and vice versa.  A more performant 
solution is to keep a private "LessonDetail"
  +attribute in the bean that is construct in the ejbLoad() method.</para>
  +   </section>
   </chapter>
  
  
  

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to