>
> I'm trying to sort out an issue with using CMP 2.0 entity
> beans. It's a hypothetical question right now since I'm not
> using CMP 2.0, but I am using a similar approach with
> EJBDoclet and CMP 1.1
>
> I'm starting from the assumption that in EJB 2.0, CMP
> entity beans are implemented by specifing an abstract base
> class containing abstract get/set methods for the beans
> properties. The container generates a concrete class (or
> some other approach) to do the handling of persistence.
>
> My question is this: since these methods are abstract, how
> can I validate input coming in via a setXXX() method? Does
> this approach mean I can no longer put logic in my entity
> beans? Does this mean I am reduced to putting a session
> bean in front of the entities and putting my validation
> there (ugly)?
The entity bean properties should be separate from CMP field. Here, we
employ a naming convention which specifies that CM[PR] fields are suffixed
with 'Field', while EJB properties are not. Thus,
public abstract String getNameField();
public abstract void setNameField(String name);
public String getName() {
return getNameField();
}
public void setName(String name) {
if (name == null)
throw new NullPointerException("Null name");
setNameField(name);
}
>
> (or am I being stupid and missing something in the spec?
> I'm looking at $10.3.1 in PFD2)
>
> As a side note, this presumably implies that value object
> creation cannot now be done by tools such as EJBDoclet
> since there is no code allowed in CMP accessor methods?
>
> I've looked for answers on forums/lists etc but couldn't
> find anything.
>
> Chris Harris
>
- Avi
--
This signature intentionally left blank.
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".