2

How can I use addSqlFunction() in spring when I configured hibernate with hibernate.cfg.xml file? Or is there any other way to use group_concat?

user1137146
  • 285
  • 1
  • 3
  • 14
  • This is explained here: [http://stackoverflow.com/questions/4955580/hibernate-how-to-use-concat-and-group-concat][1] [1]: http://stackoverflow.com/questions/4955580/hibernate-how-to-use-concat-and-group-concat – stefan.m Oct 23 '12 at 10:09

1 Answers1

2

If you’re using Spring’s HibernateTemplate to integrate with Hibernate, there’s a simple solution to this. Override Spring’s LocalSessionFactoryBean and implement the method postProcessConfiguration.

The light at the end of the tunnel (config is the object passed to you by the method postProcessConfiguration):

config.addSqlFunction( “group_concat”, new StandardSQLFunction("group_concat", new StringType());
bluish
  • 26,356
  • 27
  • 122
  • 180
Syed Wajid
  • 81
  • 9