Specified key was too long; max key length is 767

在上两篇博客中,看起来有点变扭,咱们能够看到在主键pojo类中有这样的注释:@column(length=20,name="XXX")java

其实这是在指明字段的大小,也是咋指明主键的大小。由于若是咱们不指明会报错:mysql

Specified key was too long; max key length is 767 bytessql

what  wrong????????????????????????????hibernate

咱们把hibernate生成的语句copy到mysql中code

create  table  composeIDTest
 (id  integer  not null,
  name varchar(255) not null,
  title varchar(255),
  address varchar(255),
   primary key(id,name)
)

若是这样建立就会报错,可是若是咱们这样ci

create  table  composeIDTest

 (id  integer  not null,

  name varchar(255) not null,

  title varchar(255),

  address varchar(255),

   primary key(id,name(100))

)

错误消除!primary key长度有限制!!get

参考这篇博客:http://www.zhihu.com/question/19798234博客

相关文章
相关标签/搜索