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 约束的状态
oracle在创建约束后默认状态是enabled VALIDATED
SQL> create table T2
2 (
3 VID NUMBER,
4 VNAME VARCHAR2(10) not null,
5 VSEX VARCHAR2(10) not null
6 )
7 /
Table created
SQL> alter table t2 add constraints PK_T primary key (vid); ......
今天复习第三章,本来算起来应该是第二章的,但是第二章的内容是介绍数据库的管理工具,而对于我们而言,这些相对来说没有多大的必要,所以,现在步入复习Oracle实例的管理。这章的内容包括初始化参数文件的维护和管理,以各种不同的方式启动和概念比数据库Oracle Instance,以及对Oracle I ......
1. Read the Data Block.
2. Read the Row Header.
3. Check the Lock Byte to determine whether there's an ITL entry.
4. Read the ITL entry to determine the Transaction ID (Xid).
5. Read the Transaction Table using the Transaction ID. If the transaction has been committed and has a System Commit ......
1.概述
索引是应用设计和开发的一个重要方面。如果有太多的索引,DML 的性能就会受到影响。如果索引太
少,又会影响查询(包括插入、更新和删除)的性能。要找到一个合适的平衡点,这对于应用的性能至关
重要。
我常常发现,人们在应用开发中总是事后才想起索引。我坚持认为这是一种错误的做法。如果你知
道数据将如何 ......