Hi All,
I am using Hibernate 3 as my persistence framework.
Below is the sample hbm file I am using.
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.test.User" table="user">
<meta attribute="implements">com.test.dao.interfaces.IEntity</meta>
<id name="key" type="long" column="user_key">
<generator class="increment" />
</id>
<property name="userName" column="user_name" not-null="true" type="string" />
<property name="password" column="password" not-null="true" type="string" />
<property name="firstName" column="first_name" not-null="true" type="string" />
<property name="lastName" column="last_name" not-null="true" type="string" />
<property name="createdDate" column="created_date" not-null="true" type="timestamp" insert="false" update="false" />
<property name="createdBy" column="created_by" not-null="true" type="string" update="false" />
</class>
</hibernate-mapping>
I am added a post-update listener. What it will do is if there any updations perfomed on User then it will be invoked and cahnges will be inserted to audit table.
Below is the sample implementation for postupdate event.
Code:
public void onPostUpdate(PostUpdateEvent event)
{
LogHelper.info(logger, "Begin - onPostUpdate "
+ event.getEntity().getClass().getSimpleName());
if (!this.checkForAudit(event.getEntity().getClass().getSimpleName()))
{
// check do we need to audit it.
}
// Get Attribute Names
String[] attrNames = event.getPersister().getEntityMetamodel()
.getPropertyNames();
Object[] oldobjectValue = c
Object[] newObjectValue = event.getState();
this.auditDetailsEvent(attrNames, oldobjectValue, newObjectValue);
LogHelper.info(logger, "End - onPostUpdate");
// return false;
}
Here is my requirement. event.getPersister().getEntityMetamodel()
.getPropertyNames(); or event.getOldState(); or event.getState();
must return attribute names or value which i can update or insert.
Is there any way to control the return values of above one's.
Can any one suggest me regarding this problem.
Thanks,
Narendra