Configure sessionFactory with Spring, Hibernate and LocalSessionFactoryBuilder

前端 未结 3 1355
醉酒成梦
醉酒成梦 2021-01-02 23:20

I\'m trying to create sessionFactory bean using spring 3.2 and hibernate 4. I used the following code for that. But the problem is buildSessionFactory()

3条回答
  •  鱼传尺愫
    2021-01-02 23:49

    You could also write the code without chaining:

    LocalSessionFactoryBuilder builder = new LocalSessionFactoryBuilder(dataSource());
    builder.scanPackages("com.mypackages");
    builder.addProperties(hibernateProperties());
    return builder.buildSessionFactory();
    

    Slightly more verbose but not as smelly as @SuppressWarnings("deprecation")

提交回复
热议问题