加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

如何手动将String映射到postgresql文本而不仅仅是varchar(254)?

发布时间:2020-12-13 18:05:35 所属栏目:百科 来源:网络整理
导读:我使用slick2 postgresql 9.3 playframework 2 我的数据模型是: class Page(tag:Tag) extends Table[(Long,Long,String,Option[Long],Option[Long])](tag,"Page"){ def id=column[Long]("ID",O.PrimaryKey) def subId=column[Long]("subject") def title=co
我使用slick2 postgresql 9.3 playframework 2

我的数据模型是:

class Page(tag:Tag) extends Table[(Long,Long,String,Option[Long],Option[Long])](tag,"Page"){
  def id=column[Long]("ID",O.PrimaryKey)
  def subId=column[Long]("subject")
  def title=column[String]("Title",O.NotNull)
  def describe=column[String]("Describe")
  def profile=column[String]("Profile")
  def icon=column[Long]("icon")
  def resId=column[Long]("Picture")
  def * = (id,subId,title,describe,profile,icon.?,resId.?)
  def page_sub=foreignKey("PA_SU_FK",subject)(_.id)
  def page_res=foreignKey("PA_RE_FK",resId,resource)(_.id)

}

问题是列描述是String,并将在数据库中映射为varchar(254).但实际上,这个专栏可能很长,我的意思是它可能有1000-3000个字符.
如何手动将其映射到Datamodel中的文本?

这适用于PostgreSQL:
def profile=column[String]("Profile",O.DBType("TEXT"))

或者你可以建立一个自定义的TypeMapper,我从来没有建立一个,但有很多帖子,如this SO问题或this问题.

希望能帮助到你.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读