hibernate根据时间日期来查询oracle数据库
使用模糊查询:
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-mm-dd");
Date startdate = sdf.parse(start_date);
Date enddate = sdf.parse(end_date);
List list = sess.createCriteria(MyTabel.class)
.add( Restrictions.eq("clinid", start_clinId) )
.add( Restrictions.between("idate", startdate, enddate) ) .list();
使用oracle本身的函数
session.find("from Weather w where w.recordTiime=to_date('"+ datestr +"', 'yyyy-mm-dd hh24:mi:ss')")
其中datestr是形如"2005-03-01 11:30:00"格式的字符串
Spring集成hibernate
public List findResult(final String bankid,final String begintime,final String endtime) {
log.debug("finding Result Ydopehb instances");
java.util.Date bd=DateUtil.getDate(begintime);
java.util.Date ed=DateUtil.getDate(endtime);
java.sql.Date bdate = new java.sql.Date(bd.getTime());
java.sql.Date edate = new java.sql.Date(ed.getTime());
try {
String queryString = "from Ydopehb where bankid='"
+ bankid +"' and feetime between :begintime and :endtime ";
return getHibernateTemplate().findByNamedParam(queryString, new String[]{"begintime","endtime"}, new java.sql.Date[]{bdate,edate}) ;
} catch (RuntimeException re) {
log.error("find Result failed", re);
throw re;
}
}
其中DateUtil 是自定义的工具类,用来在Date类型和String类型之间互相转换。
相关文档:
oracle constraints 应用
oracle constraints可以设置为立即检查或者当时事务提交时检查。
可以在创建约束的时候指定是deferrable。然后通过set constraints xxx set deferred或者immediate,也可以在seesion级别设定所有约束为deferred或者immediate(alter seesion set constraints deferred/immediat ......
1. ASCII
返回与指定的字符对应的十进制数;
SQL> select ascii(A) A,ascii(a) a,ascii(0) zero,ascii( ) space from dual;
A A ZERO SPACE
--------- --------- --------- ---------
65 97 48 32
2. CHR
给出整数,返回对应的字符;
SQL> select chr(54740) zhao,chr(65) chr65 from dual;
ZH C
-- -
赵 A
......
1.概述
索引是应用设计和开发的一个重要方面。如果有太多的索引,DML 的性能就会受到影响。如果索引太
少,又会影响查询(包括插入、更新和删除)的性能。要找到一个合适的平衡点,这对于应用的性能至关
重要。
我常常发现,人们在应用开发中总是事后才想起索引。我坚持认为这是一种错误的做法。如果你知
道数据将如何 ......
declare
v_isexist number(3,0):=0;
begin
select count(1) into v_isexist from sys.all_objects where owner = 'TEST' and object_type = 'TABLE' and object_name = 'TAB1';
if v_isexist>0 ......
从在Linux上安装Oracle到投入使用才几天,碰到的问题就成百上千的。在使用客户端连接远程Oracle数据库服务器时,出现了listener refused the connection with the following error ora-12519 Listener refused the connection with the following error:ORA-12519, TNS:no appropriate service handler foundThe Connection ......