当前位置:首页 > Hibernate

hibernate模糊查询的几种方式

canca18年前 (2008-08-09)Hibernate747

(一)

        Session session=HibernateUtil.getSessionFactory().getCurrentSession();

        session.beginTransaction();

        String strSQL="from Classes as a where a.classno like :name";

        Query query = session.createQuery(strSQL);
       
        query.setString("name", "%"+OId+"%");
       
         List result=query.list();
(二)
       Session session=HibernateUtil.getSessionFactory().getCurrentSession();

   

   session.beginTransaction();

   

   List result=session.createQuery("from Classes as a where a.classno like     

   '%"+OId+"%'").list();

 (三)

     Session session=HibernateUtil.getSessionFactory().getCurrentSession();

  session.beginTransaction();

       

  List result=session.createQuery("from Classes as a where a.classno 

  like :name").setParameter("pid",OId).list();

扫描二维码推送至手机访问。

版权声明:本文由Ant.Master's Blog发布,如需转载请注明出处。

本文链接:https://iant.work/post/379.html

标签: Hibernate
分享给朋友:

“ hibernate模糊查询的几种方式” 的相关文章

Hibernate + Proxool连接池

费话就不说啦! hibernate.cfg.xml 加入: <property name="hibernate.proxool.pool_alias">dbpool</property>  <property name="hibernate.prox…

关于VO、PO的理解

O/R Mapping 是 Object Relational Mapping(对象关系映射)的缩写。通俗点讲,就是将对象与关系数据库绑定,用对象来表示关系数据。在O/R Mapping的世界里,有两个基本的也是重要的东东需要了解,即VO,PO。 VO,值对象(Value Object),...…

java.lang.IllegalAccessError: tried to access method net.sf.ehcache.CacheManager.()V from class org.hibernate.cache.EhCacheProvider

今天把项目从Tomcat下转移到JBOSS了,启动JBOSS服务器之后出了,控制台输出了java.lang.IllegalAccessError: tried to access method net.sf.ehcache.CacheManager.<init>()V from clas…

hibernate's hbm 文件配置

外键:<many-to-one> 被外键引用:<set>…

hibernate 查询时 对日期的比较

Hibernate's Built-in criterion: Between (using with Date) In this section, you will learn to use "between" i.e.one of the built-in hibernate criterion…

hibernate oracle char character 只查出一个字符

public List queryTradeConfirmBusinFlag() {            final String sql …

发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。