{"action":"created","issue":{"url":"https://api.github.com/repos/javers/javers/issues/455","repository_url":"https://api.github.com/repos/javers/javers","labels_url":"https://api.github.com/repos/javers/javers/issues/455/labels{/name}","comments_url":"https://api.github.com/repos/javers/javers/issues/455/comments","events_url":"https://api.github.com/repos/javers/javers/issues/455/events","html_url":"https://github.com/javers/javers/issues/455","id":188751169,"number":455,"title":"MySQL error: Specified key was too long; max key length is 767 bytes","user":{"login":"vrozkovec","id":135681,"avatar_url":"https://avatars.githubusercontent.com/u/135681?v=3","gravatar_id":"","url":"https://api.github.com/users/vrozkovec","html_url":"https://github.com/vrozkovec","followers_url":"https://api.github.com/users/vrozkovec/followers","following_url":"https://api.github.com/users/vrozkovec/following{/other_user}","gists_url":"https://api.github.com/users/vrozkovec/gists{/gist_id}","starred_url":"https://api.github.com/users/vrozkovec/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vrozkovec/subscriptions","organizations_url":"https://api.github.com/users/vrozkovec/orgs","repos_url":"https://api.github.com/users/vrozkovec/repos","events_url":"https://api.github.com/users/vrozkovec/events{/privacy}","received_events_url":"https://api.github.com/users/vrozkovec/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-11-11T12:35:21Z","updated_at":"2016-11-11T13:06:00Z","closed_at":null,"body":"Hi, I'm initializing repository this way:\r\n```\r\nJaversSqlRepository sqlRepository = SqlRepositoryBuilder.sqlRepository()\r\n\t.withConnectionProvider(connectionProvider)\r\n\t.withDialect(DialectName.MYSQL)\r\n\t.build();\r\nJavers javers = JaversBuilder.javers().registerJaversRepository(sqlRepository).build();\r\n```\r\nhowever I get an error in the application:\r\n\r\n```\r\n13:22:18,689  INFO SqlRepositoryBuilder:55 - starting up SQL repository module ...\r\n13:22:18,719  INFO Java8AddOns:13 - loading Java8 add-ons ...\r\n13:22:18,738  INFO ScannerModule:28 - using FIELD mappingStyle\r\n13:22:18,753  INFO JaversSchemaManager:244 - creating javers table jv_commit_property ...\r\n13:22:18,753  INFO SchemaManagerImpl:51 - creating entity with name jv_commit_property using ddl:\r\nCREATE TABLE jv_commit_property (\r\nproperty_name VARCHAR(200),\r\nproperty_value VARCHAR(200),\r\ncommit_fk BIGINT,\r\nCONSTRAINT jv_commit_property_pk PRIMARY KEY(commit_fk, property_name),\r\nCONSTRAINT jv_commit_property_commit_fk FOREIGN KEY(commit_fk) REFERENCES jv_commit(commit_pk)\r\n) ENGINE = InnoDB\r\n13:22:18,755  WARN RequestCycleExtra:346 - ********************************\r\n13:22:18,755  WARN RequestCycleExtra:347 - Handling the following exception\r\norg.polyjdbc.core.exception.SchemaManagerException: [DDL_ERROR] Failed to run DDL:\r\nCREATE TABLE jv_commit_property (\r\nproperty_name VARCHAR(200),\r\nproperty_value VARCHAR(200),\r\ncommit_fk BIGINT,\r\nCONSTRAINT jv_commit_property_pk PRIMARY KEY(commit_fk, property_name),\r\nCONSTRAINT jv_commit_property_commit_fk FOREIGN KEY(commit_fk) REFERENCES jv_commit(commit_pk)\r\n) ENGINE = InnoDB\r\n\tat org.polyjdbc.core.schema.SchemaManagerImpl.ddl(SchemaManagerImpl.java:91)\r\n\tat org.polyjdbc.core.schema.SchemaManagerImpl.create(SchemaManagerImpl.java:52)\r\n\tat org.javers.repository.sql.schema.JaversSchemaManager.ensureTable(JaversSchemaManager.java:245)\r\n\tat org.javers.repository.sql.schema.JaversSchemaManager.ensureSchema(JaversSchemaManager.java:42)\r\n\tat org.javers.repository.sql.JaversSqlRepository.ensureSchema(JaversSqlRepository.java:81)\r\n\tat org.javers.core.JaversBuilder.build(JaversBuilder.java:107)\r\n\tat cz.jaclean.pages.TestPage.onInitialize(TestPage.java:56)\r\n\tat org.apache.wicket.Component.fireInitialize(Component.java:891)\r\n\tat org.apache.wicket.MarkupContainer.internalInitialize(MarkupContainer.java:1081)\r\n\tat org.apache.wicket.Page.isPageStateless(Page.java:465)\r\n\tat org.apache.wicket.request.handler.render.WebPageRenderer.isPageStateless(WebPageRenderer.java:287)\r\n\tat org.apache.wicket.request.handler.render.WebPageRenderer.shouldRenderPageAndWriteResponse(WebPageRenderer.java:329)\r\n\tat org.apache.wicket.request.handler.render.WebPageRenderer.respond(WebPageRenderer.java:193)\r\n\tat org.apache.wicket.core.request.handler.RenderPageRequestHandler.respond(RenderPageRequestHandler.java:175)\r\n\tat org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:895)\r\n\tat org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:64)\r\n\tat org.apache.wicket.request.cycle.RequestCycle.execute(RequestCycle.java:265)\r\n\tat org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:222)\r\n\tat org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:293)\r\n\tat org.apache.wicket.protocol.http.WicketFilter.processRequestCycle(WicketFilter.java:261)\r\n\tat org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:203)\r\n\tat org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:284)\r\n\tat org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1668)\r\n\tat org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:581)\r\n\tat org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)\r\n\tat org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:548)\r\n\tat org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:226)\r\n\tat org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1180)\r\n\tat org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:511)\r\n\tat org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)\r\n\tat org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1112)\r\n\tat org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)\r\n\tat org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:134)\r\n\tat org.eclipse.jetty.server.Server.handle(Server.java:523)\r\n\tat org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:320)\r\n\tat org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:251)\r\n\tat org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:273)\r\n\tat org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:95)\r\n\tat org.eclipse.jetty.io.SelectChannelEndPoint$2.run(SelectChannelEndPoint.java:93)\r\n\tat org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.executeProduceConsume(ExecuteProduceConsume.java:303)\r\n\tat org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.produceConsume(ExecuteProduceConsume.java:148)\r\n\tat org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.run(ExecuteProduceConsume.java:136)\r\n\tat org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:671)\r\n\tat org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:589)\r\n\tat java.lang.Thread.run(Thread.java:745)\r\nCaused by: java.sql.SQLSyntaxErrorException: Specified key was too long; max key length is 767 bytes\r\n\tat com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:560)\r\n\tat com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:537)\r\n\tat com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:527)\r\n\tat com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:115)\r\n\tat com.mysql.cj.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2011)\r\n\tat com.mysql.cj.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:1964)\r\n\tat com.mysql.cj.jdbc.StatementImpl.executeInternal(StatementImpl.java:891)\r\n\tat com.mysql.cj.jdbc.StatementImpl.execute(StatementImpl.java:795)\r\n\tat com.mchange.v2.c3p0.impl.NewProxyStatement.execute(NewProxyStatement.java:75)\r\n\tat org.polyjdbc.core.schema.SchemaManagerImpl.ddl(SchemaManagerImpl.java:88)\r\n\t... 44 more\r\n13:22:18,757  WARN RequestCycleExtra:348 - ********************************\r\n13:22:18,758 ERROR DefaultExceptionMapper:170 - Unexpected error occurred\r\norg.polyjdbc.core.exception.SchemaManagerException: [DDL_ERROR] Failed to run DDL:\r\nCREATE TABLE jv_commit_property (\r\nproperty_name VARCHAR(200),\r\nproperty_value VARCHAR(200),\r\ncommit_fk BIGINT,\r\nCONSTRAINT jv_commit_property_pk PRIMARY KEY(commit_fk, property_name),\r\nCONSTRAINT jv_commit_property_commit_fk FOREIGN KEY(commit_fk) REFERENCES jv_commit(commit_pk)\r\n) ENGINE = InnoDB\r\n\tat org.polyjdbc.core.schema.SchemaManagerImpl.ddl(SchemaManagerImpl.java:91)\r\n\tat org.polyjdbc.core.schema.SchemaManagerImpl.create(SchemaManagerImpl.java:52)\r\n\tat org.javers.repository.sql.schema.JaversSchemaManager.ensureTable(JaversSchemaManager.java:245)\r\n\tat org.javers.repository.sql.schema.JaversSchemaManager.ensureSchema(JaversSchemaManager.java:42)\r\n\tat org.javers.repository.sql.JaversSqlRepository.ensureSchema(JaversSqlRepository.java:81)\r\n\tat org.javers.core.JaversBuilder.build(JaversBuilder.java:107)\r\n\tat cz.jaclean.pages.TestPage.onInitialize(TestPage.java:56)\r\n\tat org.apache.wicket.Component.fireInitialize(Component.java:891)\r\n\tat org.apache.wicket.MarkupContainer.internalInitialize(MarkupContainer.java:1081)\r\n\tat org.apache.wicket.Page.isPageStateless(Page.java:465)\r\n\tat org.apache.wicket.request.handler.render.WebPageRenderer.isPageStateless(WebPageRenderer.java:287)\r\n\tat org.apache.wicket.request.handler.render.WebPageRenderer.shouldRenderPageAndWriteResponse(WebPageRenderer.java:329)\r\n\tat org.apache.wicket.request.handler.render.WebPageRenderer.respond(WebPageRenderer.java:193)\r\n\tat org.apache.wicket.core.request.handler.RenderPageRequestHandler.respond(RenderPageRequestHandler.java:175)\r\n\tat org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:895)\r\n\tat org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:64)\r\n\tat org.apache.wicket.request.cycle.RequestCycle.execute(RequestCycle.java:265)\r\n\tat org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:222)\r\n\tat org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:293)\r\n\tat org.apache.wicket.protocol.http.WicketFilter.processRequestCycle(WicketFilter.java:261)\r\n\tat org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:203)\r\n\tat org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:284)\r\n\tat org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1668)\r\n\tat org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:581)\r\n\tat org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)\r\n\tat org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:548)\r\n\tat org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:226)\r\n\tat org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1180)\r\n\tat org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:511)\r\n\tat org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)\r\n\tat org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1112)\r\n\tat org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)\r\n\tat org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:134)\r\n\tat org.eclipse.jetty.server.Server.handle(Server.java:523)\r\n\tat org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:320)\r\n\tat org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:251)\r\n\tat org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:273)\r\n\tat org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:95)\r\n\tat org.eclipse.jetty.io.SelectChannelEndPoint$2.run(SelectChannelEndPoint.java:93)\r\n\tat org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.executeProduceConsume(ExecuteProduceConsume.java:303)\r\n\tat org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.produceConsume(ExecuteProduceConsume.java:148)\r\n\tat org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.run(ExecuteProduceConsume.java:136)\r\n\tat org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:671)\r\n\tat org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:589)\r\n\tat java.lang.Thread.run(Thread.java:745)\r\nCaused by: java.sql.SQLSyntaxErrorException: Specified key was too long; max key length is 767 bytes\r\n\tat com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:560)\r\n\tat com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:537)\r\n\tat com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:527)\r\n\tat com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:115)\r\n\tat com.mysql.cj.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2011)\r\n\tat com.mysql.cj.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:1964)\r\n\tat com.mysql.cj.jdbc.StatementImpl.executeInternal(StatementImpl.java:891)\r\n\tat com.mysql.cj.jdbc.StatementImpl.execute(StatementImpl.java:795)\r\n\tat com.mchange.v2.c3p0.impl.NewProxyStatement.execute(NewProxyStatement.java:75)\r\n\tat org.polyjdbc.core.schema.SchemaManagerImpl.ddl(SchemaManagerImpl.java:88)\r\n\t... 44 more\r\n```\r\n\r\nWhen I try to run DDL  separately in the database:\r\n\r\n```\r\nCREATE TABLE jv_commit_property (\r\nproperty_name VARCHAR(200),\r\nproperty_value VARCHAR(200),\r\ncommit_fk BIGINT,\r\nCONSTRAINT jv_commit_property_pk PRIMARY KEY(commit_fk, property_name),\r\nCONSTRAINT jv_commit_property_commit_fk FOREIGN KEY(commit_fk) REFERENCES jv_commit(commit_pk)\r\n) ENGINE = InnoDB\r\n```\r\n\r\nI get the same error..\r\n\r\nAs you do not specify encoding and my database used utf16_czech_ci collation, this maxed out allowed 767 bytes for a key size. After setting it to utf8_czech_ci, the problem went away.\r\nEither it would be good to specify encoding or check encoding first and then set a limit on a key.\r\n\r\nRelated discussions: \r\n[#1071 - Specified key was too long; max key length is 767 bytes](http://stackoverflow.com/questions/1814532/1071-specified-key-was-too-long-max-key-length-is-767-bytes)\r\n[UTF8, UTF16, and UTF32](http://stackoverflow.com/questions/496321/utf8-utf16-and-utf32)"},"comment":{"url":"https://api.github.com/repos/javers/javers/issues/comments/259953288","html_url":"https://github.com/javers/javers/issues/455#issuecomment-259953288","issue_url":"https://api.github.com/repos/javers/javers/issues/455","id":259953288,"user":{"login":"vrozkovec","id":135681,"avatar_url":"https://avatars.githubusercontent.com/u/135681?v=3","gravatar_id":"","url":"https://api.github.com/users/vrozkovec","html_url":"https://github.com/vrozkovec","followers_url":"https://api.github.com/users/vrozkovec/followers","following_url":"https://api.github.com/users/vrozkovec/following{/other_user}","gists_url":"https://api.github.com/users/vrozkovec/gists{/gist_id}","starred_url":"https://api.github.com/users/vrozkovec/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vrozkovec/subscriptions","organizations_url":"https://api.github.com/users/vrozkovec/orgs","repos_url":"https://api.github.com/users/vrozkovec/repos","events_url":"https://api.github.com/users/vrozkovec/events{/privacy}","received_events_url":"https://api.github.com/users/vrozkovec/received_events","type":"User","site_admin":false},"created_at":"2016-11-11T13:06:00Z","updated_at":"2016-11-11T13:06:00Z","body":"I guess it must have been this one:\r\nPRIMARY KEY(commit_fk, property_name)\r\n\r\nproperty_name length is 200 x 4 bytes is 800 bytes for utf16\r\nproperty_name length is 200 x 3 bytes is 600 bytes for utf8\r\n\r\nsame goes for other tables. Just try to run it on InnoDB engine and utf16, you'll hit this error.\r\nAlso see third list item [here](http://dev.mysql.com/doc/refman/5.7/en/innodb-restrictions.html)\r\n"}}
{"actor":{"display_login":"vrozkovec"}}