未知实体:com.boto.SpringHibernatee.entity.Employee;
Unknown entity: com.boto.SpringHibernatee.entity.Employee;
当我调用 .setAnnotatedClasses(Employee.class)
时它正在工作
但是当我调用 .setAnnotatedPackage("com.boto.SpringHibernatee.entity")
它抛出未知的实体异常
@Bean
public LocalSessionFactoryBean sessionfactory() {
LocalSessionFactoryBean sessionFactoryBean = new LocalSessionFactoryBean();
sessionFactoryBean.setHibernateProperties(getproperties());
sessionFactoryBean.setDataSource(datasource);
sessionFactoryBean.setAnnotatedPackages("com.boto.SpringHibernatee.entity");
return sessionFactoryBean;
}
@Bean
public LocalSessionFactoryBean sessionfactory() {
LocalSessionFactoryBean sessionFactoryBean = new LocalSessionFactoryBean();
sessionFactoryBean.setHibernateProperties(getproperties());
sessionFactoryBean.setDataSource(datasource);
sessionFactoryBean.setAnnotatedClasses(Employee.class);
return sessionFactoryBean;
}
使用 setPackagesToScan
@Bean
public LocalSessionFactoryBean sessionfactory() {
LocalSessionFactoryBean sessionFactoryBean = new LocalSessionFactoryBean();
sessionFactoryBean.setHibernateProperties(getproperties());
sessionFactoryBean.setDataSource(datasource);
sessionFactoryBean.setPackagesToScan( new String[] {"com.boto.SpringHibernatee.entity"});
return sessionFactoryBean;
}
当我调用 .setAnnotatedClasses(Employee.class)
时它正在工作
但是当我调用 .setAnnotatedPackage("com.boto.SpringHibernatee.entity")
它抛出未知的实体异常
@Bean
public LocalSessionFactoryBean sessionfactory() {
LocalSessionFactoryBean sessionFactoryBean = new LocalSessionFactoryBean();
sessionFactoryBean.setHibernateProperties(getproperties());
sessionFactoryBean.setDataSource(datasource);
sessionFactoryBean.setAnnotatedPackages("com.boto.SpringHibernatee.entity");
return sessionFactoryBean;
}
@Bean
public LocalSessionFactoryBean sessionfactory() {
LocalSessionFactoryBean sessionFactoryBean = new LocalSessionFactoryBean();
sessionFactoryBean.setHibernateProperties(getproperties());
sessionFactoryBean.setDataSource(datasource);
sessionFactoryBean.setAnnotatedClasses(Employee.class);
return sessionFactoryBean;
}
使用 setPackagesToScan
@Bean
public LocalSessionFactoryBean sessionfactory() {
LocalSessionFactoryBean sessionFactoryBean = new LocalSessionFactoryBean();
sessionFactoryBean.setHibernateProperties(getproperties());
sessionFactoryBean.setDataSource(datasource);
sessionFactoryBean.setPackagesToScan( new String[] {"com.boto.SpringHibernatee.entity"});
return sessionFactoryBean;
}