Code:
public interface AObject
{
String getId();
void setId(String id);
...
}
public abstract class AbstractAObject implements AObject
{
public String getId()
{
return id;
}
public void setId(String id)
{
this.id = id;
}
...
}
public class DPDemandHBImpl extends AbstractDPDemand (extends AbstractAObject)
{
....
}
<class name="DPDemandHBImpl" table="DP_DEMANDS" lazy="true" >
<id name="id" type="string" unsaved-value="null" >
<column name="ID" sql-type="number" not-null="true"/>
<generator class="com.amfitel.common.hb.StringSequenceGenerator">
<param name="sequence" >DP_DEMANDS_SEQ</param>
</generator>
</id>
<property name="num" type="string" />
<property name="createDate" type="date" column="CR_DATE" />
<property name="descr" type="com.amfitel.common.hb.StringClobType" >
</property>
<many-to-one name="creator" column="CREATOR_ID" not-null="true" class="DPUserJDBCImpl" />
</class>
In Struts' action I'm create this object by Factory pattern and then call saveOrUpdate method...
Code:
DPDemand demand=null;
demand=DPObjectFactory.getInstance().
getDemand().create();
demand.setCreateDate(new Date());
demand.setCreator((DPUser)req.getUserPrincipal());
log.debug("demand=" + demand);
BeanUtils.copyProperties(demand, form);
demand.save();