首页 > 解决方案 > 迁移中 hibernate.hbm2ddl.auto 的问题

问题描述

我已经将一个 spring-boot 项目从 MySQL 迁移到 SQL Server。我没有必要的角色来使用 hibernate.hbm2ddl.auto = update。如何在没有系统管理员访问权限的情况下进行更新?

我需要更新,因为我不能丢失记录

2021-07-21 | 13:30:17.660 |  INFO | main                 | o.h.t.h.SchemaUpdate      | HHH000228: Running hbm2ddl schema update
2021-07-21 | 13:30:17.692 |  WARN | main                 | .e.j.s.SqlExceptionHelper | SQL Error: 229, SQLState: S0005
2021-07-21 | 13:30:17.692 | ERROR | main                 | .e.j.s.SqlExceptionHelper | The SELECT permission was denied on the object 'sequences', database 'mssqlsystemresource', schema 'sys'.
2021-07-21 | 13:30:17.692 |  WARN | main                 | ddedWebApplicationContext | Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory
2021-07-21 | 13:30:17.692 |  INFO | main                 | o.a.c.c.StandardService   | Stopping service [Tomcat]

标签: spring-boothibernatejpahbm2ddl

解决方案


我不知道您是如何调用 hbm2ddl 但您可以指定一个输出文件,然后手动应用这些语句。您可以通过javax.persistence.schema-generation.scripts.create-target参数进行配置。有关详细信息,请参阅文档:https ://docs.jboss.org/hibernate/orm/5.5/userguide/html_single/Hibernate_User_Guide.html#configurations-hbmddl


推荐阅读