The full code for these classes is shown below:
package curam.mypackage; import java.util.Set; import com.google.inject.Inject; import curam.mypackage.struct.MyNewEntityDtls; import curam.util.exception.InformationalException; import curam.util.persistence.helper.SingleTableLogicallyDeleteableEntityImpl; import curam.util.type.Date; import curam.util.type.DateRange; /** * Standard implementation of {@linkplain MyNewEntity}. */ public class MyNewEntityImpl extends SingleTableLogicallyDeleteableEntityImpl<MyNewEntityDtls> implements MyNewEntity { @Inject private MyParentEntityDAO myParentEntityDAO; @Inject private MyChildEntityDAO myChildEntityDAO; protected MyNewEntityImpl() { /* Protected no-arg constructor for use only by Guice */ } /* * Field getters */ /** * {@inheritDoc} */ public String getName() { return getDtls().name; } /** * {@inheritDoc} */ public DateRange getDateRange() { return new DateRange(getDtls().startDate, getDtls().endDate); } /** * {@inheritDoc} */ public MYNEWENTITYTYPEEntry getType() { return MYNEWENTITYTYPEEntry.get(getDtls().typeCode); } /* * Related-entity getters */ /** * {@inheritDoc} */ public Set<MyChildEntity> getMyChildren() { return myChildEntityDAO.searchByParent(this); } /** * {@inheritDoc} */ public MyParentEntity getMyParentEntity() { final long myParentEntityID = getDtls().myParentEntityID; if (myParentEntityID == 0) { return null; } else { return myParentEntityDAO.get(myParentEntityID); } } /* * Setters */ public void setMyParentEntity(MyParentEntity value) { // TODO Auto-generated method stub } public void setName(String value) { // TODO Auto-generated method stub } public void setType(final MYNEWENTITYTYPEEntry value) { // TODO Auto-generated method stub } /* * Validation */ public void mandatoryFieldValidation() { // TODO Auto-generated method stub } public void crossFieldValidation() { // TODO Auto-generated method stub } public void crossEntityValidation() { // TODO Auto-generated method stub } }
package curam.mypackage; import java.util.Set; import curam.util.persistence.StandardDAO; /** * Data access for {@linkplain MyChildEntity}. */ public interface MyChildEntityDAO extends StandardDAO<MyChildEntity> { /** * Searches all the instances belonging to the specified parent. * * @param myNewEntity * the parent to search for * @return all the instances belonging to the specified parent, or * an empty set if none found. */ public Set<MyChildEntity> searchByParent( final MyNewEntity myNewEntity); }