hibernate裡面用in查詢

2021-09-12 23:06:05 字數 1052 閱讀 4890

hibernate中各種型別的查詢條件拼接:

一、正常的傳參查詢(精確查詢)

string shopattendancecode = queryhash.get("shopattendancecode");

if (!stringutils.isempty(shopattendancecode)) ", shopattendancecode);

}二、正常的傳參查詢(模糊查詢)

string likeshopcode = queryhash.get("likeshopcode");

if (!stringutils.isempty(likeshopcode)) ", "%" + likeshopcode + "%");

}三、日期型別的查詢

string plaindate = queryhash.get("plaindate");

if (!stringutils.isempty(plaindate)) ", stringconverters.todatepattern(plaindate,"yyyy-mm-dd"));//黃顏色部分返回date型別

}四、日期範圍查詢

string startdate = queryhash.get("startdate");

string enddate = queryhash.get("enddate");

if (!stringutils.isempty(startdate) && !stringutils.isempty(enddate)) ", stringconverters.todatepattern(startdate,"yyyy-mm-dd"));

conditionhash.put("plaindate <= ? ", stringconverters.todatepattern(enddate,"yyyy-mm-dd"));

}五、in條件查詢

string inshopcode = queryhash.get("inshopcode");

if (!stringutils.isempty(inshopcode)) ) ", str);

}

Hibernate增刪改查介面

我演示的是乙個書籍管理系統中書籍資訊增刪改查的乙個例項 首先,先配置hibernate環境,這個之前介紹過,這裡就不做詳細介紹了 建立增刪改查介面 public inte ce bookdao具體實現增刪改查的方法 public book selectbook int id catch hibern...

Hibernate入門 增刪改查

一 hibernate入門案例剖析 建立實體類student 並重寫tostring方法 public class student public void setsid integer sid public integer getage public void setage integer age ...

MongoDB裡面怎麼 查最值

怎麼在mongodb裡面怎麼 查最值 就好像sql語句的select max row form 我現在知道了,現在拿出來和大家分享一下吧 dbobject ref new basicdbobject ref.put auth id authid ref.put weibo type weibotyp...