当前位置: 代码迷 >> J2EE >> hibernate 动态配置表,该怎么处理
  详细解决方案

hibernate 动态配置表,该怎么处理

热度:62   发布时间:2016-04-19 22:47:15.0
hibernate 动态配置表
最近用hibernate的时候由于数据量过大,需要动态创建表,但hibernate怎么动态配置呢?求各位大虾指点
------解决方案--------------------
首先配置<property name="hibernate.hbm2ddl.auto">create</property>
自己写一个main或者其他测试类 加入如下代码。ok
Configuration conf=new Configuration();
  conf.configure("/hibernate.cfg.xml");
  SchemaExport dbExport=new SchemaExport(conf);
  dbExport.create(true, true);
------解决方案--------------------
如果我没理解错,你是要用hibernate映射动态表名吗?这个不难继承DefaultNamingStrategy实现classToTableName
  相关解决方案