2012-05-11 60 views
2

如何使用addSqlFunction()在春天的時候我配置了hibernate.cfg.xml文件冬眠?或者還有其他方式可以使用group_concat嗎?如何使用GROUP_CONCAT在休眠+春

+0

這是這裏解釋: [http://stackoverflow.com/questions/ 4955580 /休眠-如何使用的-的concat-和基團的concat] [1] [1]:http://stackoverflow.com/questions/4955580/hibernate-how-to-use -concat-和基團的concat –

回答

2

如果你使用Spring的HibernateTemplate來與Hibernate的整合,有一個簡單的解決這個。覆蓋Spring的LocalSessionFactoryBean並實施方法postProcessConfiguration

在隧道的端部的光(配置是通過該方法postProcessConfiguration傳遞給你的對象):

config.addSqlFunction(「group_concat」, new StandardSQLFunction("group_concat", new StringType());