Hi everyone,
i am having a problem updating my database, below are my codes:
my mapping:
Code:
<hibernate-mapping auto-import="true" default-lazy="true">
<class name="net.nationalpayment.pps.model.RecentItem" table="USR_MRU">
<composite-id name="id" class="net.nationalpayment.pps.model.RecentItemId" unsaved-value="undefined">
<key-property name="userId" column="UMR_USRID" type="string" length="30"/>
<key-property name="itemDate" column="UMR_DT" type="timestamp" length="6"/>
</composite-id>
<property name="itemValue" column="UMR_MRUVAL" type="string" length="30"/>
<property name="itemLink" column="UMR_MRULINK" type="string" length="255"/>
<property name="type" column="UMR_TYPE" type="string" length="255"/>
<property name="auditInfo" type="net.nationalpayment.pps.model.AuditInfoUserType">
<column name="LAST_UPDATED_ON"/>
<column name="LAST_UPDATED_BY"/>
<column name="CREATED_DATE"/>
<column name="CREATED_BY"/>
</property>
</class>
</hibernate-mapping>
java code in dao:
Code:
Session session = this.getSessionFactory().openSession();
String queryStr = "update USR_MRU set UMR_DT=to_date('"+ this.convertDateToString(recentItem.getId().getItemDate()) +"', 'yyyy-mm-dd hh24:mi:ss'), UMR_TYPE='"+recentItem.getType()+"' where UMR_USRID='"+recentItem.getId().getUserId()+"' and UMR_MRUVAL='"+recentItem.getItemValue()+"'";
try{
session.createSQLQuery(queryStr);
}finally{
session.close();
}
private String convertDateToString(java.util.Date date){
java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
return sdf.format(date);
}
i used hibernate 3.1.3, spring and oracle db. my problem is it doesn't update the record in the database. does anyone encountered and solved this issue? please share your thought. thanks in advance.
regards,
thinkspace