Specified key was too long; max key length is 767

Recommended for you: Get network issues from WhatsUp Gold. Not end users.

In the last two blog, looks a bit torque, we can see that there are such annotation in the primary key of the POJO class:@column(length=20,name="XXX")

In fact, this is specified in the field size is specified, how key size. Because if we do not specify the wrong:

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

what  wrong????????????????????????????

We have generated hibernate statement copy to MySQL

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

If you create will error, but if we do

create  table  composeIDTest

 (id  integer  not null,

  name varchar(255) not null,

  title varchar(255),

  address varchar(255),

   primary key(id,name(100))

)

Error elimination! Primary key length limit!!

Reference to this blog

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download

Posted by Myron at January 10, 2014 - 7:50 PM