hibernate中使用schemaExport生成数据表报错解决方法
2017-07-17 11:31
288 查看
【解决方法】
1.hibernate中使用schemaexport生成数据表,很多教材是教你这么写的:
SchemaExport schemaExport = new SchemaExport(new Configuration().configure());
schemaExport.create(true, true);
因为我们现在基本都是使用hibernate 5.x,所以当你这么写的时候,IDE会提醒你这种方法已经不推荐使用了。
2.解决方法:将以上代码改成以下代码:
ServiceRegistry serviceRegistry = (ServiceRegistry) new StandardServiceRegistryBuilder().configure().build();
MetadataImplementor metadataImplementor = (MetadataImplementor) new MetadataSources(serviceRegistry).buildMetadata();
SchemaExport export = new SchemaExport(serviceRegistry, metadataImplementor);
export.create(true, true);
重新运行,(如果你的hibernate和数据库驱动的jar已经正确导入),应该是OK了。
1.hibernate中使用schemaexport生成数据表,很多教材是教你这么写的:
SchemaExport schemaExport = new SchemaExport(new Configuration().configure());
schemaExport.create(true, true);
因为我们现在基本都是使用hibernate 5.x,所以当你这么写的时候,IDE会提醒你这种方法已经不推荐使用了。
2.解决方法:将以上代码改成以下代码:
ServiceRegistry serviceRegistry = (ServiceRegistry) new StandardServiceRegistryBuilder().configure().build();
MetadataImplementor metadataImplementor = (MetadataImplementor) new MetadataSources(serviceRegistry).buildMetadata();
SchemaExport export = new SchemaExport(serviceRegistry, metadataImplementor);
export.create(true, true);
重新运行,(如果你的hibernate和数据库驱动的jar已经正确导入),应该是OK了。
相关文章推荐
- hibernate中使用schemaExport生成数据表报错解决方法
- 一口一口吃掉Hibernate(一)——使用SchemaExport生成数据表
- Hibernate(一)——使用SchemaExport生成数据表
- hibernate使用SchemaExport自动生成数据表
- Hibernate5.x 使用SchemaExport生成数据表
- 一口一口吃掉Hibernate(一)——使用SchemaExport生成数据表
- Hibernate ORM入门02-使用SchemaExport生成数据表
- 系统学习hibernate之一:利用hibernate中的SchemaExport生成数据表
- Hibernate5.X的SchemaExport的使用方法
- Hibernate初学者---schemaExport自动生成联合主键关联数据表
- Hibernate中使用SchemaExport来自动生成数据库中的表时,控制台有sql语句,但是数据库中无新建的表
- hibernate使用SchemaExport生成对应的数据库表
- SchemaExport 类使用(自动生成数据表)
- 系统学习hibernate之一:利用hibernate中的SchemaExport生成数据表
- Hibernate 使用SchemaExport自动生成表
- Hibernate4注解开发,使用hbm2ddl生成表时,不生成外键的解决方法
- Hibernate使用SchemaExport和AnnotationConfiguration生成表结构
- 利用hibernate中的SchemaExport生成数据表
- MyEclipse生成的Spring+Hibernate无法保存数据问题的解决方法
- Hibernate5.X的SchemaExport的使用方法