当前位置: 代码迷 >> SQL >> spring治理hibernate后sql例子
  详细解决方案

spring治理hibernate后sql例子

热度:99   发布时间:2016-05-05 12:11:26.0
spring管理hibernate后sql例子

1、执行单行查询

public String backLsh()	{		String sql = "select case" +		     " when to_number(substr(t.slid, 13, 8)) <" +		     " to_number(to_char(sysdate, 'yyyymmdd')) then" +		     " 'HLW-RK-CSDJ-' || to_char(sysdate, 'yyyymmdd') || '0001'" +		     " when to_number(substr(t.slid, 13, 8)) =" +		     " to_number(to_char(sysdate, 'yyyymmdd')) then" +		     " substr(t.slid," +		     " 1," +		     " length(t.slid) -" +		     " length(to_number(substr(t.slid, 21, 4)) + 1)) ||" +		     " to_char(to_number(substr(t.slid, 21, 4)) + 1)" +		     " end" +		     " from (select slbh slid" +		     " from slbh_list where  ywbh = 'HLW-RK-CSDJ') t";				return this.getSession().createSQLQuery(sql).uniqueResult().toString();	}

?

?

2、执行更新

public boolean saveRkslbhzdz(String slbh){        String sql = "update slbh_list set slbh='" + slbh + "'where ywbh = 'HLW-RK-CSDJ'";           this.getSession().createSQLQuery(sql).executeUpdate();        return true;}

?

  相关解决方案