tags:

views:

21

answers:

1

Hi all,

I have tables, called Customer, Orders.... Each table contains createdBy, CreatedDate,ModifiedBy, ModifiedDate. How do i fill this information for all tables without duplicating these columns in each entity and mapping file? I am using Java 1.4, hibernate ORM model. Currently i have create one base class (CoreDomainObject) which has these properties and other entities will extend the parent class (CoreDomainObject).And in All mapping file will have the column to attribute mapping independently.

public class CoreDomainObject
{
    private String createdBy;
    private String modifiedBy;
    private Date createdDate;
    private Date modifiedDate;

    public String getCreatedBy() {
    return createdBy;
    }
.........
..... for other attributes
}

public class Employee extends CoreDomainObject{
....
}

Mapping File

<class name="com.sss.sample.entity.Employee"
        table="T_LOOKUP_Employee">
        <id name="empId" type="integer" column="EMP_ID">
            <generator class="native" />
        </id>

        <property name="employeeName" column="emp_name" type="string"/>
        <property name="active" column="ACTV" type="boolean"/>

        <property name="createdBy" column="CRTD_USER_ID" type="string"/>
        <property name="creationDate" column="CRDT_DATE" type="timestamp" />
        <property name="modifiedBy" column="UPDT_USER_ID" type="string"/>
        <property name="modificationDate" column="UPDT_DATE" type="timestamp"/>

    </class>