当我使用 hibernate.cfg.xml 文件配置 hibernate 时,如何在 spring 中使用 addSqlFunction()
?或者还有其他方法可以使用group_concat吗?
最佳答案
如果您使用 Spring 的 HibernateTemplate 与 Hibernate 集成,有一个简单的解决方案。重写 Spring 的 LocalSessionFactoryBean
并实现方法 postProcessConfiguration
。
隧道尽头的光明(config是通过postProcessConfiguration
方法传递给您的对象):
config.addSqlFunction( “group_concat”, new StandardSQLFunction("group_concat", new StringType());
关于spring - 如何在 Hibernate + Spring 中使用 group_concat,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10556368/