我正在尝试创建一个 SessionFactory bean。我的代码如下:
@Bean
public SessionFactory sessionFactory() {
return new LocalSessionFactoryBuilder(dataSource()).scanPackages("com.package").buildSessionFactory();
}
@Bean
public DataSource dataSource() {
BasicDataSource dataSource = new BasicDataSource();
dataSource.setDriverClassName("com.mysql.jdbc.Driver");
dataSource.setUrl("jdbc:mysql://localhost:3306/csu_library");
dataSource.setUsername("csulibrary");
dataSource.setPassword("csulibrary");
dataSource.setMaxActive(10);
dataSource.setMaxIdle(5);
dataSource.setInitialSize(5);
return dataSource;
}
抛出的异常如下:
Caused by: java.lang.ClassCastException: org.hibernate.mapping.SingleTableSubclass cannot be cast to org.hibernate.mapping.RootClass