如何使用 Hibernate 在实体中创建 属性 table?

How to create property table in an entitiy with Hibernate?

我有一个用户实体。我想在没有其他实体的情况下为这个用户实体创建属性 class。 我的用户实体是;

@Data
@Entity
@Table
@EqualsAndHashCode(onlyExplicitlyIncluded = true)
public class User {
          ****
@ElementCollection(fetch = FetchType.EAGER)
@CollectionTable(name = "user_properties", joinColumns = @JoinColumn(name = "user_id", referencedColumnName = "id"))
@MapKeyColumn(name = "key")
@Column(name = "value")
private Map<String, String> properties = new HashMap<>();

public String setProperty(String key,String value) {
    return properties.put(key,value);
}

public String getProperty(String key) {
    return properties.get(key);
}
}

此代码无法创建 user_properties table,我遇到了错误;

Table 'test.user_properties' doesn't exist

如何在没有属性新实体的情况下创建属性 table?

MySQL 不支持列名如 'key' 和 'value'。我更改了列名,它对我有用。