Hello,

I've been searching through the xdoclet-user archives trying to find an
answer to my current predicament, which is how to get concrete (i.e. non-
abstract) getters I've defined in a CMP 2.0 entity bean to be used by the
corresponding xdoclet-generated xxxCMP class to set a field in a related
value object.

More specifically, I've defined a getName method which returns the
concatenation of the firstName and lastName persistent fields, and the name
field itself appears in the VO, but in the getPersonVO() method of the
PersonCMP class, the name field is not set by the getter I have defined, so
the name field is always null in the VO.

Here's are code snippets, to further illustrate...

from PersonBean.java

/**
 * Entity representing a Person.
 * 
 * @author J. Patterson Waltz
 * 
 * @ejb.bean
 *        name="Person"
 *        type="CMP"
 *        cmp-version="${ejb.cmp.version}"
 *        primkey-field="personID"
 *        view-type="local"
 *
 * @ejb.value-object

..

    /**
     * personID (Primary Key)
     * 
     * @ejb.persistence
     * @ejb.interface-method
     */
    public abstract Integer getPersonID();
    public abstract void setPersonID(Integer id);

    /**
     * @ejb.persistence
     * @ejb.interface-method
     */
    public abstract String getFirstName();
    
    /**  @ejb.interface-method */
    public abstract void setFirstName(String firstName);

    /**
     * @ejb.persistence
     * @ejb.interface-method
     */
    public abstract String getLastName();
    
    /** @ejb.interface-method */
    public abstract void setLastName(String lastName);
    
    /**
     * @ejb.interface-method
     */
    public String getName() {
        return getFirstName()+" "+getLastName();
    }

    /**
     * @ejb.persistence
     * @ejb.interface-method
     */
    public abstract String getSalutation();

    /** @ejb.interface-method */
    public abstract void setSalutation(String salutation);
    
and from PersonCMP.java:

   public contacts.transfer.PersonTO getPersonTO()
   {
      PersonTO = new contacts.transfer.PersonTO();
      try
         {
            PersonTO.setPersonID( getPersonID() );
            PersonTO.setFirstName( getFirstName() );
            PersonTO.setLastName( getLastName() );
            PersonTO.setSalutation( getSalutation() );
 
The two possible solutions I've seen mentioned here (both in the following
post http:// thread.gmane.org/gmane.comp.java.xdoclet.user/9978) include
either defining these "helper" methods in a parent class subclassed by the
VO or else using a per-bean merge point to do the same. Neither method
appeals to my sense of economy, as they would require me to redeclare in
their entirety methods I have *already* declared in my entity bean.

Is there no way to have a non-persisted non-abstract getter carried directly
through to the related CMP class and used to set the value in the
corresponding value object?

Thanks in advance for any assistance you can provide.

Patterson Waltz




-------------------------------------------------------
This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170
Project Admins to receive an Apple iPod Mini FREE for your judgement on
who ports your project to Linux PPC the best. Sponsored by IBM.
Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php
_______________________________________________
xdoclet-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-user

Reply via email to