java - Spring 和 JPA : Create database schema and tables on demand

标签 java spring jpa schema

在 JPA/Spring 中是否有可能在运行时创建/删除具有自定义名称和根据表(由 @Entity 注释给出)的数据库模式,例如当用户按下按钮时?

我只知道 javax.persistence.schema-generation 属性,它们在我的应用程序启动时执行并使用预定义的模式名称。

我正在寻找的一个简短(和简化)示例:

假设我有两个实体,DogCat。当用户按下按钮时,将创建一个新模式 animals1,其中包含两个表 DogCat。所有查询现在都转到架构 animals1。当用户第二次按下按钮时,将创建一个包含两个表的不同模式 animals2,所有查询现在都转到 animals2

我想我可以在 Spring 中施展魔法,但我不知道从哪里开始。如果有任何提示,我将不胜感激。

最佳答案

关于java - Spring 和 JPA : Create database schema and tables on demand,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39288383/

相关文章:

spring - 在Grails G-Func功能测试中引导 hibernate

java - Spring security 返回 401,将日期作为输入发送到其余 Controller

java - 使用 Spring Boot、JPA 通过引用关联实体

java - Hibernate 使用 Uuid 生成

java - 当我修复此 Android 编译器错误时,出现多捕获异常

java - 如何在进度微调器中显示数字

java - 不能连接 String[] 因为它存储在一个对象中

java - 从基于配置的服务 bean 切换到基于注释的服务 bean 时的 TransactionProxyFactoryBean

java - 我如何使用改造和recyclerView解析json对象

java.lang.NoSuchMethodError : javax. persistence.JoinColumn.foreignKey