开发者

HQL concat function

开发者 https://www.devze.com 2023-03-07 21:58 出处:网络
Customer{ String customerName @OneToMany Set users; } User{ String userName; } when i do this: select c.customerName as customerName ,concat(u.userName) as userNames from Customer c join c.user开
Customer{
  String customerName
  @OneToMany
  Set users;
}
User{
  String userName;
}

when i do this:

select c.customerName as customerName ,concat(u.userName) as userNames from Customer c join c.user开发者_运维知识库s as u

hibernate don't return the result i expected.


Unfortunately hibernate does not have an SQL aggregate function that combines strings. There is no standard SQL aggregate function for this either so each database tends to have it's own. An example would be NexusDB 3.x's LIST() which compiles a comma-separated list of non-null values in the set.

SELECT c.customerName as customerName , LIST(u.userName) as userNames 
FROM Customer c 
JOIN c.users as u
GROUP BY c.customerName;
0

精彩评论

暂无评论...
验证码 换一张
取 消