{"action":"opened","issue":{"url":"https://api.github.com/repos/jhipster/generator-jhipster/issues/8274","repository_url":"https://api.github.com/repos/jhipster/generator-jhipster","labels_url":"https://api.github.com/repos/jhipster/generator-jhipster/issues/8274/labels{/name}","comments_url":"https://api.github.com/repos/jhipster/generator-jhipster/issues/8274/comments","events_url":"https://api.github.com/repos/jhipster/generator-jhipster/issues/8274/events","html_url":"https://github.com/jhipster/generator-jhipster/issues/8274","id":358892511,"node_id":"MDU6SXNzdWUzNTg4OTI1MTE=","number":8274,"title":"Uploading an image bigger than 65,535 bytes causes SQLException","user":{"login":"amatosg","id":42916953,"node_id":"MDQ6VXNlcjQyOTE2OTUz","avatar_url":"https://avatars0.githubusercontent.com/u/42916953?v=4","gravatar_id":"","url":"https://api.github.com/users/amatosg","html_url":"https://github.com/amatosg","followers_url":"https://api.github.com/users/amatosg/followers","following_url":"https://api.github.com/users/amatosg/following{/other_user}","gists_url":"https://api.github.com/users/amatosg/gists{/gist_id}","starred_url":"https://api.github.com/users/amatosg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amatosg/subscriptions","organizations_url":"https://api.github.com/users/amatosg/orgs","repos_url":"https://api.github.com/users/amatosg/repos","events_url":"https://api.github.com/users/amatosg/events{/privacy}","received_events_url":"https://api.github.com/users/amatosg/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-09-11T05:32:21Z","updated_at":"2018-09-11T05:32:21Z","closed_at":null,"author_association":"NONE","body":"<!--\r\n- Please follow the issue template below for bug reports.\r\n- If you have a support request rather than a bug, please use [Stack Overflow](http://stackoverflow.com/questions/tagged/jhipster) with the JHipster tag.\r\n- For bug reports it is mandatory to run the command `jhipster info` in your project's root folder, and paste the result here.\r\n- Tickets opened without any of these pieces of information will be **closed** without any explanation.\r\n-->\r\n\r\n##### **Overview of the issue**\r\n\r\n<!-- Explain the bug, if an error is being thrown a stack trace helps -->\r\nEntity created through JDL. Field is `ImageBlog` which creates column type `blob`. The max size for a blob column is `65,535` bytes. If I upload a file bigger than that, it causes an exception:\r\n\r\n<details>\r\n<summary>SQLException</summary>\r\n<pre>\r\nCaused by: java.sql.SQLException: Data too long for column 'avatar' at row 1\r\nQuery is: insert into test_entity (avatar, avatar_content_type) values (?, ?), parameters [ bytearray:����JFIF��\r\n                                                                                                                XICC_PROFILE\r\n                                                                                                                            HLinomntrRGB XYZ �\t1acspMSFTIEC sRGB���-HP  cprtP3desc�lwtpt�bkptrXYZgXYZ,bXYZ@dmndTpdmdd��vuedL�view�$lumi�meas\r\n                                                                     $tech0\r\n                                                                           rTRC<\r\n                                                                               gTRC<\r\n                                                                                   bTRC<\r\n                                                                                       textCopyright (c) 1998 Hewlett-Packard CompanydescsRGB IEC61966-2.1sRGB IEC61966-2.1XYZ �Q�XYZ XYZ o�8��XYZ b����XYZ $����descIEC http://www.iec.chIEC http://www.iec.chdesc.IEC 61966-2.1 Default RGB colour space - sRGB.IEC 61966-2.1 Default RGB colour space - sRGBdesc,Reference Viewing Condition in IEC6...\r\n\tat org.mariadb.jdbc.internal.util.LogQueryTool.exceptionWithQuery(LogQueryTool.java:153)\r\n\tat org.mariadb.jdbc.internal.protocol.AbstractQueryProtocol.executePreparedQuery(AbstractQueryProtocol.java:972)\r\n\tat org.mariadb.jdbc.MariaDbPreparedStatementServer.executeInternal(MariaDbPreparedStatementServer.java:376)\r\n\t... 197 common frames omitted\r\n\r\n2018-09-11 00:06:01.764  WARN 22705 --- [  XNIO-2 task-7] .m.m.a.ExceptionHandlerExceptionResolver : Resolved exception caused by Handler execution: org.springframework.dao.DataIntegrityViolationException: could not execute statement; SQL [n/a]; nested exception is org.hibernate.exception.DataException: could not execute statement\r\n</pre>\r\n</details>\r\n\r\n\r\nIn the front end it only shows `Internal Server Error` and entity cannot be saved.\r\n\r\n##### **Motivation for or Use Case**\r\n\r\n<!-- Explain why this is a bug for you -->\r\nUser should get a reason why the entity is not being saved.\r\n\r\n##### **Reproduce the error**\r\n\r\n<!-- For bug reports, an unambiguous set of steps to reproduce the error -->\r\nGenerate Entity with a field ImageBlog\r\nCreate an entity and add a file bigger that 65535 bytes.\r\n\r\n##### **Related issues**\r\n\r\n<!-- Has a similar issue been reported before? Please search both closed & open issues -->\r\nSearched, but none found.\r\n\r\n##### **Suggest a Fix**\r\n\r\n<!-- If you can't fix the bug yourself, perhaps you can point to what might be\r\n  causing the problem (line of code or commit) -->\r\nThere could be 3 solutions:\r\n1. Change from blob (67kb) to mediumblob (16mb). This could increase the db size, but there could also be a configuration to set the max size allowed, like 1, 5, 10, 15MB. Again, this could be configured in JDL, something lile `avatar ImageBlob 5M`\r\n2. Resize the image on the fly just before uploading to < 65KB.\r\n3. Raise an error indicating that the file must be smaller than 65kb (I think this is too small)\r\n\r\n##### **JHipster Version(s)**\r\n\r\n```\r\ntest@0.0.0 /Users/alejandro/IdeaProjects/test\r\n└── generator-jhipster@5.3.1\r\n\r\n```\r\n\r\n\r\n##### **JHipster configuration, a `.yo-rc.json` file generated in the root folder**\r\n\r\n\r\n<details>\r\n<summary>.yo-rc.json file</summary>\r\n<pre>\r\n{\r\n  \"generator-jhipster\": {\r\n    \"promptValues\": {\r\n      \"packageName\": \"com.tester.testering\",\r\n      \"nativeLanguage\": \"es\"\r\n    },\r\n    \"jhipsterVersion\": \"5.3.1\",\r\n    \"applicationType\": \"monolith\",\r\n    \"baseName\": \"test\",\r\n    \"packageName\": \"com.tester.testering\",\r\n    \"packageFolder\": \"com/tester/testering\",\r\n    \"serverPort\": \"8080\",\r\n    \"authenticationType\": \"jwt\",\r\n    \"cacheProvider\": \"ehcache\",\r\n    \"enableHibernateCache\": true,\r\n    \"websocket\": false,\r\n    \"databaseType\": \"sql\",\r\n    \"devDatabaseType\": \"mariadb\",\r\n    \"prodDatabaseType\": \"mariadb\",\r\n    \"searchEngine\": false,\r\n    \"messageBroker\": false,\r\n    \"serviceDiscoveryType\": \"eureka\",\r\n    \"buildTool\": \"maven\",\r\n    \"enableSwaggerCodegen\": false,\r\n    \"jwtSecretKey\": \"bXktc2VjcmV0LXRva2VuLXRvLWNoYW5nZS1pbi1wcm9kdWN0aW9uLWFuZC10by1rZWVwLWluLWEtc2VjdXJlLXBsYWNl\",\r\n    \"clientFramework\": \"angularX\",\r\n    \"useSass\": true,\r\n    \"clientPackageManager\": \"npm\",\r\n    \"testFrameworks\": [\r\n      \"gatling\"\r\n    ],\r\n    \"jhiPrefix\": \"jhi\",\r\n    \"enableTranslation\": true,\r\n    \"nativeLanguage\": \"es\",\r\n    \"languages\": [\r\n      \"es\"\r\n    ]\r\n  }\r\n}\r\n</pre>\r\n</details>\r\n\r\n\r\n##### **JDL for the Entity configuration(s) `entityName.json` files generated in the `.jhipster` directory**\r\n\r\n<details>\r\n<summary>JDL entity definitions</summary>\r\n\r\n<pre>\r\nentity TestEntity {\r\n  avatar ImageBlob\r\n}\r\n\r\n</pre>\r\n</details>\r\n\r\n\r\n##### **Environment and Tools**\r\n\r\njava version \"1.8.0_181\"\r\nJava(TM) SE Runtime Environment (build 1.8.0_181-b13)\r\nJava HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode)\r\n\r\ngit version 2.16.2\r\n\r\nnode: v8.11.3\r\n\r\nnpm: 6.4.1\r\n\r\nyeoman: 2.0.5\r\n\r\nDocker version 18.06.1-ce, build e68fc7a\r\n\r\ndocker-compose version 1.22.0, build f46880f\r\n##### **Entity configuration(s) `entityName.json` files generated in the `.jhipster` directory**\r\n\r\n<details>\r\n<summary>TestEntity</summary>\r\n<pre>\r\n{\r\n    \"name\": \"TestEntity\",\r\n    \"fields\": [\r\n        {\r\n            \"fieldName\": \"avatar\",\r\n            \"fieldType\": \"byte[]\",\r\n            \"fieldTypeBlobContent\": \"image\"\r\n        }\r\n    ],\r\n    \"relationships\": [],\r\n    \"changelogDate\": \"20180911045959\",\r\n    \"entityTableName\": \"test_entity\",\r\n    \"dto\": \"no\",\r\n    \"pagination\": \"no\",\r\n    \"service\": \"no\",\r\n    \"jpaMetamodelFiltering\": false,\r\n    \"fluentMethods\": true,\r\n    \"clientRootFolder\": \"\",\r\n    \"applications\": \"*\"\r\n}\r\n</pre>\r\n</details>\r\n\r\n<!--\r\nIf the error is during an entity creation or associated with a specific entity.\r\nIf you are using JDL, please share that configuration as well.\r\n-->\r\n\r\n##### **Browsers and Operating System**\r\n\r\n<!-- What OS are you on? is this a problem with all browsers or only IE8? -->\r\nmacOS & Chrome, but it's irrelevant.\r\n\r\n- [X] Checking this box is mandatory (this is just to show you read everything)\r\n\r\n<!-- Love JHipster? Please consider supporting our collective:\r\n👉  https://opencollective.com/generator-jhipster/donate -->\r\n"}}
{"actor":{"display_login":"amatosg"}}