如何在Hibernate Criteria中设置两列连接结果的投影

时间:2014-10-28 06:20:51

标签: sql hibernate

我有一个问题是在Hibernate中将两列的连接结果转换为单个结果 标准。

SQL查询:

SELECT firstName || ' ' || lastName FROM person WHERE active_yn='Y'

如何在Hibernate Criteria中为两列的连续结果设置投影?

1 个答案:

答案 0 :(得分:0)

/ 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");

More ref