You can also directly map a table to a table without creating a KeyValuePair class
For the map property with key-value pairs stored in MY_MAP_TABLE, it is defined as a property with the name "settings":
Define a property:
@ElementCollection (fetch=FetchType.EAGER) @CollectionTable(name="MY_MAP_TABLE" , joinColumns=@JoinColumn (name="ID")) @MapKeyColumn(name="name") @Column(name="value") public Map<String, String> getSettings() { return settings; }
And a table for storing a card:
CREATE TABLE MY_MAP_TABLE ( ID NUMBER not null REFERENCES MY_PARENT_TABLE(ID), NAME VARCHAR2(256) not null, VALUE VARCHAR2(256) not null, PRIMARY KEY (ID , NAME) );
source share