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 were 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")
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top