1

I uses JPABuddy to generate an init Liquibase db for MySQL 8.0.33 DB. I notices that for nvarchar datatype it uses character set utf8mb3, collation utf8mb3_general_ci which are deprecated, instead MySQL recommend to use utf8mb4.

This is the responses when you try to use nvarchar:

0 row(s) affected, 1 warning(s): 3720 NATIONAL/NCHAR/NVARCHAR implies the character set UTF8MB3, which will be replaced by UTF8MB4 in a future release. Please consider using CHAR(x) CHARACTER SET UTF8MB4 in order to be unambiguous.

The solution is to change instances of nvarchar to varchar in the generated file, but that would defeat the purpose of Liquibase flexible changelog.

  • Hello! I didn't quite understand what result you want to achieve. Could you clarify it a bit? 1) JPA Buddy generates nvarchar for @Nationalized attributes. Are you expecting another type to be generated? 2) Why would using varchar instead of nvarchar defeat the purpose of Liquibase's flexible changelog? – Georgii Vlasov Jun 27 '23 at 16:58
  • The intended result is that if you use MySQL, nvarchar will be converted into varchar because MySQL doesn't differentiate between the 2, as you can see in the response inline code. You can confirm this because if you use any method to generate changelog file: `generateChangeLog`, `diff` or `hibernate.hbm2ddl.auto: create-drop`. You will see that nvarchar and varchar converted into the same type when create table. 1) I expect nvarchar, varchar to both be `utf8mb4`. – vunhatchuong Jun 27 '23 at 21:32
  • From what I understand, based on this discussion (https://hibernate.zulipchat.com/#narrow/stream/132096-hibernate-user/topic/Hibernate.205.20to.206.20Migration.20Issue) between Gavin King and Jonathan Baker, the current issue with Hibernate is that it generates a simple varchar for @Nationalized attributes, but this is actually a mistake that will be fixed soon. The correct generation should be `varchar($l) character set utf8` – Georgii Vlasov Jun 28 '23 at 05:10
  • I have created a ticket for JPA Buddy to fix the generation pattern, and we will try to do it as soon as possible :) You can track its status here: https://issues.jpa-buddy.com/issue/JPAB-2585. – Georgii Vlasov Jun 28 '23 at 05:30
  • As a workaround for now, you can use the columnDefinition. For example: columnDefinition = "varchar(255) character set utf8" Then, JPA Buddy will generate the script taking into account what is specified in the columnDefinition. – Georgii Vlasov Jun 28 '23 at 05:33

0 Answers0