使用JPA存儲Map <String,String> - Storing a Map<String,String> using JPA

問題:

I am wondering if it is possible using annotations to persist the attributes map in the following class using JPA2 我想知道是否可以使用註釋使用JPA2在以下類中保留attributes映射

public class Example {
    long id;
    // ....
    Map<String, String> attributes = new HashMap<String, String>();
    // ....
}

As we already have a pre existing production database, so ideally the values of attributes could map to the following existing table: 由於我們已經有一個預先存在的生產數據庫,因此理想情況下, attributes值可以映射到以下現有表:

create table example_attributes {
    example_id bigint,
    name varchar(100),
    value varchar(100));

解決方案:

參考: https://stackoom.com/en/question/EEqH
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章