开发者

use of @Lob for field in playframework

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜