使用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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章