开发者

use of @Lob for field in playframework

开发者 https://www.devze.com 2023-04-01 01:08 出处:网络
In the play! tutorial,the content field of model Post is annotated as @Lob.I tried this, and when postgres was used as db,found that the table Post has a column named content which has a value 133414

In the play! tutorial,the content field of model Post is annotated as @Lob.I tried this, and when postgres was used as db,found that the table Post has a column named content which has a value 133414 instead of a long string, which was the post content.The column type is shown as 'text' where as other String fields in Entity wer开发者_开发知识库e character varying

Suppose,I want to search for posts that contain a certain word in their content,how would I formulate the query? Will I have to remove the @Lob annotation and let postgres store the content as varchar in the content column?


A @Lob is by definition a Large Object. That can be stored as binary data or character data. Searching in lobs/clob/blob can be very difficult and is, in most cases, not optimized. I would suggest using more traditionnal types such as text, varchar. Those are indexable and thus are more performant. (in most cases), you might have to define column size also.

You can precise them using the column annotation :

@Column(type = "TEXT")
0

精彩评论

暂无评论...
验证码 换一张
取 消