Can we concatenate two properties in Hibernate HQL query?

前端 未结 4 482
感动是毒
感动是毒 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:47

    You may create a calculated column in your entity:

    @Formula(value = " concat(first_name, ' ', last_name) ")
    private String fullName;
    

    And in your HQL you just refer to this field as you would do to any other.

    In your case, you can do:

    "select fullName from Contact"
    

提交回复
热议问题