如何在Hibernate Criteria中设置两列的串联结果的投影 [英] How to set projection for concatenated result of two columns in Hibernate Criteria
本文介绍了如何在Hibernate Criteria中设置两列的串联结果的投影的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在Hibernate中将两列的合并结果转换为单个结果时遇到问题 条件.
I have a problem to get concatenated result of two columns into single result in Hibernate Criteria.
SQL查询:
SELECT firstName || ' ' || lastName FROM person WHERE active_yn='Y'
如何在Hibernate Criteria中为两列的串联结果设置投影?
How to set projection for concatenated result of two columns in Hibernate Criteria?
推荐答案
/ an elegant alternative?
criteria.like(Expression.concat(firstname, ' ', lastName), input);
// an sql-like function?
criteria.like("concat(firstName, ' ', lastName)", input);
// perhaps a database-dependent concatenator?
criteria.like("firstName + ' ' + lastName");
criteria.like("firstName || ' ' || lastName");
这篇关于如何在Hibernate Criteria中设置两列的串联结果的投影的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文