JPA 如何将 ElementCollection 的列类型设置为 BLOB table
JPA how to set column type to be BLOB for ElementCollection table
我在我的实体 class、
中使用 Spring 使用 Hibernate JPA 启动并使用以下代码
@ElementCollection
private Map<String, String> userFiles= new HashMap<>();
生成集合tableuser_files
的地方。然而,默认的列类型是 VARCHAR(255)
,有时用户数据可能比这更长。我的问题是如何定义此 table 以将 BLOB
或 TEXT
用于列?我试图直接在那里添加 @Lob
注释但不起作用。
您尝试过以下方法吗?
@Column(columnDefinition="BLOB NOT NULL")
@MapKeyColumn(columnDefinition="BLOB NOT NULL")
见MapKeyColumn and Lob。
我在我的实体 class、
中使用 Spring 使用 Hibernate JPA 启动并使用以下代码@ElementCollection
private Map<String, String> userFiles= new HashMap<>();
生成集合tableuser_files
的地方。然而,默认的列类型是 VARCHAR(255)
,有时用户数据可能比这更长。我的问题是如何定义此 table 以将 BLOB
或 TEXT
用于列?我试图直接在那里添加 @Lob
注释但不起作用。
您尝试过以下方法吗?
@Column(columnDefinition="BLOB NOT NULL")
@MapKeyColumn(columnDefinition="BLOB NOT NULL")
见MapKeyColumn and Lob。