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); ......
ºÙºÙ£¬Õ⻹ÊÇÉÏÕÂ֪ʶÁË£¬Ö»Êǵ¥Ò»Ð´³öÀ´±È½ÏºÃÒ»µã£¬ÒòΪÉÏÃæµÄÊǽϻù´¡µÄ£¬²»ÔõÃ´Éæ¼°²Ù×÷£¬¶øÕâÀïÊÇͨ¹ý²Ù×÷³öÀ´µÄ£¬ºÇºÇ¡£
Ê×ÏÈ£¬´ò¿ªÊý¾Ý¿â·þÎñ£¬È»ºóͨ¹ý¿ØÖÆÌ¨´ò¿ªsqlplus£º
È»ºó½«Êý¾Ý¿âÉèÖÃΪֻ¶Á£ºalter database read only£»µ«ÊÇÄØ£¬ÕâÑùÊDz»Ä ......
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 ......