首页 > 其他分享 >springboot中关于自动建表,无法更新字段问题

springboot中关于自动建表,无法更新字段问题

时间:2022-11-09 14:07:30浏览次数:39  
标签:hibernate 建表 springboot -- create cache 更新 Model


一、Springboot中的配置

jpa:
database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
database: MYSQL
show-sql: true
properties:
hibernate.id.new_generator_mappings: true
hibernate.cache.use_second_level_cache: false
hibernate.cache.use_query_cache: false
hibernate.generate_statistics: false
hibernate.hbm2ddl.auto: create # 自动生成建表语句
hibernate:
naming:
physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl # 取消驼峰式命名

hibernate.hbm2ddl.auto: create # 自动生成建表语句

二、除了 create 配置,还有以下几种:

-- create ,会自动建表,全部的Model都会新建表

-- create-drop,会新建表,但会以及SessionFactory自动删除。

-- update,会自动建表,已存在的表无法更新,只会新增新添加的Model,生成表,所以这个注解无法更新已存在的表的字段属性。

--validate,会对Model和数据库表进行校验,字段属性不一致时,会报错

none,不自动建表,只基于Model的@entity和@Table映射数据库的表(字段可以不对应)

标签:hibernate,建表,springboot,--,create,cache,更新,Model
From: https://blog.51cto.com/u_15870196/5836245

相关文章