在運行時使用 Spring 在表中創建新字段 (Create new field into a table with Spring at runtime)


問題描述

在運行時使用 Spring 在表中創建新字段 (Create new field into a table with Spring at runtime)

我正在用 Java 中的 Spring Framework 開發一個 API,我必須在運行時在我的表中創建一個字段,如下所示:用戶保存一些信息(如一個簡單的字符串),這些信息變成一個字段表。

如果你有一些解決方案,請告訴我。

@Entity
@Table(name = "tb_myentity")
public class MyEntity {

    //fields, but dynamic in runtime!

}

注意:我不想用 field_name 創建一個表並製作一種關係。必須是動態字段。


參考解法

方法 1:

I would say that the answer to this is basically the same as this question even though you're using Spring instead of Hibernate as your data access framework. You'll want to just manually execute the DDL statements for ALTER TABLE ADD COLUMN to add the column, but your Entity class wouldn't dynamically have more member variables created.

(by Rhadamez Gindri HercilioC. Smith)

參考文件

  1. Create new field into a table with Spring at runtime (CC BY‑SA 2.5/3.0/4.0)

#runtime #java #field #dynamic #spring-mvc






相關問題

通過java運行的執行程序似乎超時? (Executed programs run through java seem to time out?)

Kesalahan NullPointerException dalam kode Java saya. (NullPointerException errors in my Java code.)

Hentikan proses anak ketika proses induk berhenti (Stop child process when parent process stops)

Атрымаць шлях выканання кансольнага скрыпта Python (Get the runpath of a python console-script)

選擇不包含主要類型 - 錯誤 (Selection does not contain main type - error)

在活動之間使用意圖錯誤 (using intents between activities error)

在運行時使用 Spring 在表中創建新字段 (Create new field into a table with Spring at runtime)

如何添加運行時超時以防止 java.net.SocketTimeoutException? (How do I add a runtime timeout to prevent java.net.SocketTimeoutException?)

我有什麼方法可以覆蓋 Java 中的系統屬性嗎? (Do I have any method to override System Properties in Java?)

如何計算此代碼的時間複雜度? (How can I compute the time complexity of this code?)

運行 .exe 文件生成 bt jar2exe 軟件時出現 java runtime environment not found 錯誤 (Getting java runtime enviroment not found error while running .exe file produced bt jar2exe software)

在運行時在 VBA 中顯示所有變量及其值 (Show all variables and their values in VBA during runtime)







留言討論