简体   繁体   English

Spring MVC Hibernate使用动态SQL表

[英]Spring MVC Hibernate use dynamic SQL Tables

I am creating an Spring Hibernate project where I need to dynamically create tables. 我正在创建一个Spring Hibernate项目,我需要在其中动态创建表。 The problem is that, with static/ predefined tables, we used to create POJO Entity class for Hibernate SQL table where I already have the table names & their columns. 问题在于,对于静态/预定义表,我们曾经为Hibernate SQL表创建POJO Entity类,其中我已经有了表名及其列。

In current case, I don't know the SQL tables names at development time since they will be created dynamically. 在当前情况下,我不知道开发时的SQL表名称,因为它们将动态创建。 So, what is the solution of this problem? 那么,这个问题的解决方案是什么?

I was searching for the same, I got this link. 我在寻找相同的东西,我得到了这个链接。 I still didn't understand the process, ie where to create the hibernate-mapping file, what is the name of the file. 我仍然不了解该过程,即在哪里创建hibernate-mapping文件,文件的名称是什么。 In the mapping file also, class name(entity-name) is defined in the example show in the link ie Customer . 同样在映射文件中,在链接的示例show中定义了类名(实体名),即Customer How it become dynamic? 它如何变成动态的?

您可以将表名保留为空白(不添加@Table批注),并添加“ 自定义命名策略”来解析类的表名

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM