hibernate动态建表实例解决
来源:互联网 发布:征途人物数据修改器 编辑:程序博客网 时间:2024/06/13 08:56
我这个程序的大体初衷就是在tomcat启动当中,在不重启tomcat的情况下,让hibernate帮我们动态建表,具体的实例就是:
注意下面的@Resource,这个非常重要,必须是这样,才能够获得正确的AnnotationSessionFactoryBean
@Controller
public class CustomAction extends BaseController {
@Resource
private DataSource dataSource;
@Resource
private AnnotationSessionFactoryBean annotationSessionFactoryBean;
下面就是Controller 的方法体了,
config.addAnnotatedClass(User9999.class);
@RequestMapping("test111")
public String execute() throws MappingException, IOException,
ClassNotFoundException {
SessionFactoryImpl sessionFactory = (SessionFactoryImpl) this.baseDao
.getSessionFactory();
AnnotationConfiguration config = (AnnotationConfiguration) annotationSessionFactoryBean
.getConfiguration();
Settings settings = sessionFactory.getSettings();
if (settings.isAutoUpdateSchema()) {
new SchemaUpdate(config,settings).execute(false, true);
}
return "test111";
}
- hibernate动态建表实例解决
- Hibernate HQL之动态构造实例对象
- hibernate单表实例
- hibernate 动态生成表
- hibernate 动态生成表
- hibernate 动态生成表
- hibernate动态表名
- 动态内表实例
- 动态链表实例
- Hibernate入门实例——动态组件(Dynamic components)
- Hibernate连表查询实例
- Hibernate动态映射表名
- hibernate实现动态表名
- hibernate动态表名映射
- hibernate动态表名映射
- hibernate动态表名映射
- Hibernate入门实例——自动建表
- 动态script标签解决跨域问题实例
- 大整数相加
- NEC单片机调试
- 转-vmstat命令详解
- 【实践】一个简单却五脏俱全的JavaScript“类”例子
- ctrl-c,ctrl-z,ctrl-d区别
- hibernate动态建表实例解决
- Linux VFS
- java中时期相关类——Date、DateFormat、Calendar
- 关于self.用法的一些总结
- MIB_IFROW Structure
- 下载积分
- 20110607
- Special characters
- android widget的自动更新