Example using Hattori and JPA ...
@Entity @Table(uniqueConstraints = { @UniqueConstraint(columnNames = { "name" }) }) public class Project extends AbstractPersistentObject { @Column(nullable=false) private String name; private String description; @OneToMany(cascade = CascadeType.ALL) @Cascade(value = org.hibernate.annotations.CascadeType.DELETE_ORPHAN) private List<Product> products; //getters and setters... }
If the property names are the same, itīs possible to ...
@ObjectPopulation(domainObjectClass = Project.class) public class ProjectDTO extends AbstractPersistentObjectDTO { private String name; private String description; @CollectionFieldPopulation(dtoClass = ProductDTO.class) private List<ProductDTO> products = new ArrayList<ProductDTO>();