HQL concat function
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;
精彩评论