Here's the complete code for this scenario solution:
// ... @Inject private SomeParentDAO someParentDAO; public SomeChildSummaryDetailsList listSomeChildDetails( final SomeParentKey key) throws AppException, InformationalException { // create an instance of the return struct final SomeChildSummaryDetailsList list = new SomeChildSummaryDetailsList(); // retrieve the instance of the parent entity final SomeParent someParent = someParentDAO.get(key.someParentID); // retrieve all the child instances of the entity for this // parent final Set<SomeChild> someChildren = someParent.getSomeChildren(); // map the details returned for (final SomeChild someChild : someChildren) { final SomeChildSummaryDetails someChildSummaryDetails = new SomeChildSummaryDetails(); someChildSummaryDetails.someChildID = someChild.getID(); someChildSummaryDetails.name = someChild.getName(); list.details.addRef(someChildSummaryDetails); } // return to the client return list; } // ...
Again, here is a briefer version which has no intermediate variable to hold the Set of child entity instances:
// ... public SomeChildSummaryDetailsList listSomeChildDetails( final SomeParentKey key) throws AppException, InformationalException { // create an instance of the return struct final SomeChildSummaryDetailsList list = new SomeChildSummaryDetailsList(); // retrieve the instance of the parent entity final SomeParent someParent = someParentDAO.get(key.someParentID); for (final SomeChild someChild : someParent.getSomeChildren()) { // map the details returned final SomeChildSummaryDetails someChildSummaryDetails = new SomeChildSummaryDetails(); someChildSummaryDetails.someChildID = someChild.getID(); someChildSummaryDetails.name = someChild.getName(); list.details.addRef(someChildSummaryDetails); } // return to the client return list; } // ...