spring - 如何在 Hibernate + Spring 中使用 group_concat

标签 spring hibernate

当我使用 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/

相关文章:

java - spring boot - @PostConstruct 未在 @Component 上调用

java - 如何为 SpringJUnit4ClassRunner.class 以外的类加载 @ContextConfiguration?

java - 如何在@Transactional模式下强制提交实体

java - Hibernate 语句挂起

java - 更新多对多关系 hibernate 中的对象

spring - Gradle有条件地运行多个 Spring 项目

java - Spring:我应该使用@Service然后@Autowired它,还是@Component AnnotationConfigApplicationContext

java - jhipster 示例应用程序 - 如何确保只有资源所有者才能删除它?

java - 如何从 Java 中返回通用列表中删除 'Type Safety'/'Unchecked conversion' 警告?

java - 如何为hibernate指定验证组