我有个新的业务需求 : 让用户在前台自己创建 一张表 并使用它
请问 :如何 使用Hibernate 让用户在前台动态的 创建 、修改 表 并把表 映射成JavaBean 放入Session中
用户在前台建表已经 完成了 如何生成相应映射的 javabean 并 将其放入sessionFactory 中?
请问 :如何 使用Hibernate 让用户在前台动态的 创建 、修改 表 并把表 映射成JavaBean 放入Session中
用户在前台建表已经 完成了 如何生成相应映射的 javabean 并 将其放入sessionFactory 中?
public class CustomAction extends BaseController { @Resource
private DataSource dataSource;
@Resource
private AnnotationSessionFactoryBean annotationSessionFactoryBean;
@RequestMapping("test111")
public String execute() throws MappingException, IOException,
ClassNotFoundException {
SessionFactoryImpl sessionFactory = (SessionFactoryImpl) this.baseDao
.getSessionFactory();
AnnotationConfiguration config = (AnnotationConfiguration) annotationSessionFactoryBean
.getConfiguration(); config.addAnnotatedClass(User9999.class);
Settings settings = sessionFactory.getSettings();
if (settings.isAutoUpdateSchema()) {
new SchemaUpdate(config,settings).execute(false, true);
}
return "test111";
}
}
上面是一个controller,你只要随便建一个jsp页面上面有一个form表单,和一个提交按钮就行了,然后在地址栏里面输入 http://localhost:8080/tf/test111 我的工程是tf你的我就不知道了,