JPA和PostqreSQL:长字符串持久性 [英] JPA and PostqreSQL: long string persistence
本文介绍了JPA和PostqreSQL:长字符串持久性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有人可以告诉我如何使用JPA(我使用PostgreSQL)来保留长文本吗?
Can anybody tell me how to persist long text using JPA (I use PostgreSQL)?
这是我在课堂上定义一个很长的字符串的方式:
Here's the way I defined a very long string in my class:
@Lob
private String body;
但是,这会在数据库中产生一个 charactervarying(255)类型的字段.
However, this produces a field of type charactervarying(255) in the database.
此外,我尝试使用@Column注释:
Furthermore, I've tried to use @Column annotation:
@Column(columnDefinition="TEXT")
private String body;
但是一切都是徒劳的.
对于这个问题的有用评论,我将不胜感激.
I would be gratefull for a helpfull comment on this problem.
推荐答案
@Column(columnDefinition="TEXT")
确实是做到这一点的方法.也许您必须重新生成DDL?
is indeed the way to do it. Perhaps you have to regenerate your DDL?
这篇关于JPA和PostqreSQL:长字符串持久性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文