Hi All,
I want to use a User defined SQL Procedure while updating a fld but have no clue how to do that. Following is the description of my problem statement:
I want to update a user's password. But before writing it in the DB, want to encrypt it. This encryption is done using a SQL Procedure. So tried:
Code:
String strResult = (String) this.getHibernateTemplate().execute(new HibernateCallback() {
public Object doInHibernate(Session session)
throws HibernateException {
SQLQuery query = session.createSQLQuery(
"update T_TAXPAYER_ACCOUNT set password=dbo.EncMe(" + password
+ "), reset_flg='Y' where userid='"+user_id+"'");
int iReturn = query.executeUpdate();
return iReturn + "";
}
});
where dbo.EncMe is that SQL Procedure. This gives the UnsupportedOperationException exception.
I tried another (funny) way:
Code:
aTaxPayerAccount = (TaxPayerAccount)this.getHibernateTemplate().get(
TaxPayerAccount.class, user_id);
aTaxPayerAccount.setPassword("dbo.EncMe("+password+")");
aTaxPayerAccount.setReset_flg("Y");
this.getHibernateTemplate().update(aTaxPayerAccount);
and it sure didn't work. Can anyone please suggest me how to get this done. I hope I was able to make my problem statement clear.
I would appreciate all inputs.
Thanks!!