Data Transfer Objects (DTOs) are very similar to Value Objects but are more specialized to work with Enterprise Java Beans (EJBs). There is only one implementation difference between a value object and a DTO:
com.javagen.commons.collections.DTO
interface.
DTOs allow a client to query a EJB persistence tier via a session facade pattern and receive arbitrary object trees in return that are decoupled from the underlying EJB implementation. DTOs are often coupled to EJB CMPs using a UML dependency as shown here:

Such a coupled CMP will be generated with constructors and methods for handling DTO data. Notice that the DTO declares no attributes, instead JavaGen copies them automatically from the CMP as instructed by the <<gen-copy>> dependency.
IMPORTANT: <<gen-copy>> only copies attributes not associations. For CMP coupled DTOs to work properly you must duplicate the associations among the DTOs exactly matching the cardinality and association end names of the corresponding CMP associations.
DTOs are generated with Castor XML databinding functionality. By simply running XDoclet against your DTOs (JAM has a ready-to-use Castor module) you can import and export your data as XML. If you don't plan on using Castor you can disable this feature by setting the following property:
<property name="javagen.dto.castor.xml" value="false"/>
| Stereotype | UML Element | Description |
|---|---|---|
| <<dto>> | Class | Generates Data Transfer Object |
| <<dto>> | Dependency | Couples an EJB to a DTO. Dependency direction should be from the EJB to the DTO. |
| <<gen-copy>> | Dependency | Copies attributes from one class to another. Dependency direction should be from the target class (DTO) to the source class (EJB). |
Set these properties in your build.xml or props-javagen.xml file:
| Property | Default | Description |
|---|---|---|
| javagen.dto.interface | com.javagen.commons.collections.DTO | This can be set to an empty string to deactivate or to your own implementation. |
| javagen.dto.castor.xml | true | Generates XDoclet Castor XML data-binding tags. |