I've solved this:
I had no setter methods for my non persistent fields in UserBean,
so the fields get generated in the value object, but no setter method
for these properties get generated (I don't understand why this is done
this way). As those setter methods don't exist, the CMP entity class
cannot invoke them, so they were not included in the getXXXValue method.
So I added a few empty setXXXX methods in my UserBean, and
everything is working as expected. Is this the expected behaviour?
Regards
Jose Gonzalez Gomez wrote:
I have a CMP EJB (UserBean) with several non persistent fields, and
I would like to include these fields in an automatically generated
value object. These fields are derived from other persistent fields, or
from some select methods. Is it possible to do such thing? How?
I've tried to do it, but I didn't succeed. After taking a look at
the templates I thought this wasn't possible, as the templates use the
XDtEjbPersistent:forAllPersistentFields tag for generating the fields
for the value object and setting the fields in the getXXXValue method
of the CMP entity class. But after generating the sources, I get the
following:
In the UserValue class:
private java.lang.String code;
private boolean codeHasBeenSet = false;
private boolean purchaser;
private boolean purchaserHasBeenSet = false;
private boolean approver;
private boolean approverHasBeenSet = false;
private boolean admin;
private boolean adminHasBeenSet = false;
private boolean absent;
private boolean absentHasBeenSet = false;
private java.lang.String commonName;
private boolean commonNameHasBeenSet = false;
private java.lang.String email;
private boolean emailHasBeenSet = false;
private java.util.Locale locale;
private boolean localeHasBeenSet = false;
private
com.actaris.eprocurement.domain.procurement.UserValue Substitute;
private boolean SubstituteHasBeenSet = false;
private Collection Departments = new java.util.ArrayList();
In the UserCMP class:
UserValue.setCode( getCode() );
UserValue.setAdmin( getAdmin() );
UserValue.setAbsent( getAbsent() );
if ( getSubstitute() != null )
UserValue.setSubstitute(
getSubstitute().getUserValue() );
UserValue.clearDepartments();
java.util.Iterator iDepartment =
getDepartmentsAbleToPurchaseFor().iterator();
while (iDepartment.hasNext()){
UserValue.addDepartment(
((com.actaris.eprocurement.domain.organization.LocalDepartment)iDepartment.next()).getDepartmentValue()
);
}
UserValue.cleanDepartment();
As you can see, there are a lot of fields that get generated in the
value object, but only some of them (the persistent fields) are set in
the getUserValue method. Is this a bug?
Regards
Jose
|