Hi,

I'm using xdoclet 1.2b3 to generate value objects to my entity beans,
but I came to a situation that, although interesting, I cannot resolve
regarding fields used as primary keys.

I have a customer entity bean (presented here with only the declarations
needed to describe the problem):

/**
 * @ejb.value-object
 *     name="Customer"
 *     match="*"
 */
public class CustomerBean extends EntityBean {

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

    public abstract void setUserName();

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

    /**
     * @ejb.interface-method
     * @ejb.persistence
     */
    public abstract void setEmail(String email);

    /* more fields declared here */

    /**
     * @ejb.create-method
     *     view-type="both"
     */    
    public CustomerBeanPK ejbCreate(String userName) 
        throws CreateException {

        setUserName(userName);
        
        return new CustomerBeanPK(userName);
    }

    /**
     * @ejb.interface-method
     */
    public abstract CustomerValue getCustomerValue();
    
    /**
     * @ejb.interface-method
     */
    public abstract void setCustomerValue(CustomerValue value);
}

As you can see from the code above I also have a primary key:

public class CustomerBeanPK implements java.io.Serializable {
    public String userName;
    
    public CustomerBeanPK() {
    }
    
    public CustomerBeanPK(String userName) {
        this.userName = userName;
    }

    /* other methods here: toString, equals, hasCode */
}

As can be noted from the above code sample, the userName field is used
as a primary key. 

The problem is: if a user calls getCustomerValue(), then change the name
of the userName and call setCustomerValue(), the userName field value is
changed, and I do not want this to happen. I want the userName to the
set on the entity bean creation and not changed in any way after that.

I tried to use the "match" property of @ejb.value-object to try to make
setUserName to be not included in the generated value object:

/**
 * @ejb.value-object
 *     name="Customer"
 *     match="customer"
 */
public class CustomerBean extends EntityBean {

    /**
     * @ejb.interface-method
     * @ejb.persistence
     * @ejb.value-object match="customer"
     */
    public abstract String getUserName();

    public abstract void setUserName();

    /**
     * @ejb.interface-method
     * @ejb.persistence
     * @ejb.value-object match="customer"
     */
    public abstract String getEmail();

    /**
     * @ejb.interface-method
     * @ejb.persistence
     * @ejb.value-object match="customer"
     */
    public abstract void setEmail(String email);
}

but the above does not work. The serUserName method is used in the
generated value object.

Anyone knows what should I do to make the setUserName method to not be
included in the generated value object?

Thanks,
-- 
                                      _/_/_/       _/_/_/        _/_/_/
Ivens Porto                         _/     _/    _/            _/
OSE - Open Systems Engineering     _/     _/    _/            _/
http://www.ose.com.br             _/     _/      _/_/_/      _/_/_/_/
Phone: (55) 34 - 3214-5995       _/     _/            _/    _/
Fax:   (55) 34 - 3214-5994      _/     _/            _/    _/
                                 _/_/_/        _/_/_/       _/_/_/


-------------------------------------------------------
This SF.net email sponsored by: Enterprise Linux Forum Conference & Expo
The Event For Linux Datacenter Solutions & Strategies in The Enterprise 
Linux in the Boardroom; in the Front Office; & in the Server Room 
http://www.enterpriselinuxforum.com
_______________________________________________
xdoclet-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-user

Reply via email to