Can we concatenate two properties in Hibernate HQL query?

前端 未结 4 490
感动是毒
感动是毒 2020-12-10 01:31

Lets say I have one table with two columns firstname and lastname with String datatype. Normally I write my hql query like

\"selec         


        
4条回答
  •  误落风尘
    2020-12-10 01:41

    I did it so with hql

    public List findContracts(String fullName) {
        Query q = sessionFactory.getCurrentSession().createQuery("from Contract c where :fullName = concat(c.firstname, ' ', c.lastname)");
         q.setString("fullName", fullName);
         return q.list();}
    

提交回复
热议问题