hql 中in 查询

public List<BLWasteType> findBLWasteType(List<BusinessLicense> listBL) {
        List<Long> list =new ArrayList<Long>();
        for(BusinessLicense bl :listBL){
            list.add(bl.getId());
        }
        String hql =" from BLWasteType where blid in (:blid)";
        Query query =this.createQuery(hql);
        query.setParameterList("blid", list);
        return query.list();
    }
时间: 2024-08-01 10:31:48

hql 中in 查询的相关文章

Hql 中实用查询时候 引号的使用

出错代码://List vlist = this.getHibernateTemplate().find("from AndroidCustomer ct where ct.token = "+token); 正确代码:List vlist= this.getHibernateTemplate().find("from AndroidCustomer a where a.token= '" + token+"'"); 这里的token为字符串,(

hql 中in查询

String hql="from User u where u.id in (:userlist)";   Query query = getSession().createQuery(hql);   List<Long> list =new ArrayList<Long>(); query.setParameterList("userlist",list);

HQL中的Like查询需要注意的地方

public List getOrgan(String organCode, String organName) {    String hsql;    List list; if (organCode != null && organCode.length() > 0) {     hsql = "from Ab31 where bae002 = ? and aab061 like ?";     list = getHibernateTemplate().f

hibernate查询语句hql中的占位符?参数与命名参数:name设值方式搞混

先贴出异常 Struts has detected an unhandled exception: Messages: Position beyond number of declared ordinal parameters. Remember that ordinal parameters are 1-based! Position: 1 File: org/hibernate/engine/query/spi/ParameterMetadata.java Stacktraces org.h

HQL多表查询

------------------siwuxie095 HQL 多表查询 以客户和联系人为例(一对多) 1.内连接 (1)hql 语句写法 from Customer c inner join c.linkManSet (2)具体实现 /* * (1) 创建 Query 对象 * * 调用 session 的 createQuery() 方法,参数是 hql * 语句,返回值是 Query 类型,创建以接收 */ Query query=session.createQuery("from Cu

Hibernate的HQL多表查询

HQL的内连接查询 对于HQL内链接查询,查询的是两张表的数据,这两张表的数据首先是保存在数组之中,然后在将每一个数组保存在List集合之中进行返回 代码片段: 1 @Test 2 // 内连接 3 public void fun1() { 4 SessionFactory factory = null; 5 Session session = null; 6 Transaction tx = null; 7 try { 8 factory = Tools.getSessionFactory()

hibernate中带查询条件的分页

所谓分页,从数据库中分,则是封装一个分页类.利用分页对象进行分页. 但,分页往往带查询条件. 分页类的三个重要数据:[当前页码数],[数据库中的总记录数],[每页显示的数据的条数] 原理:select * from  [表名] where   [字段名]  like   ['%条件%']    limit  [开始查询的索引],[每页显示的数据] 带查询条件的分页分两步 (1)第一步:查询出符合条件的数据的总条数 ---->select count(*) from [表名] where  [字段

Hibernate 的查询语言 HQL 与高级查询

Hibernate  的查询语言 HQL  与高级查询 数据库操作实现类的开发 import java.util.List; import org.hibernate.Query; import org.hibernate.SQLQuery; import org.hibernate.Session; import org.hibernate.Transaction; import org.sf.dao.IDepartmentDao; import org.sf.entity.Departmen

HQL和SQL查询

转自http://blog.csdn.net/aaa1117a8w5s6d/article/details/7757097 HQL和SQL的区别 标签: sqlhibernatejavasessionuser数据库 2012-07-17 22:03 11614人阅读 评论(0) 收藏 举报 目录(?)[+] hql是面向对象查询,格式:from + 类名 + 类对象 + where + 对象的属性 sql是面向数据库表查询,格式:from + 表名 + where + 表中字段 1.查询 一般在