Is there any way to change the datatype of a field when generated a table through @Entity Annotation in JPA Springboot?

huangapple go评论82阅读模式
英文:

Is there any way to change the datatype of a field when generated a table through @Entity Annotation in JPA Springboot?

问题

如何在使用JPA和SpringBoot的@Entity注解生成字段时更改字段的数据类型?我有一个名为Product的类,其中包含一个名为productId的字段,其数据类型为UUID,而JPA生成了二进制类型的字段。

英文:

How to change the data type of the field when generated through @Entity Annotation using JPA and SpringBoot? I have a class name as Product which contains a field name as productId having a data type of UUID and JPA generated the field of type binary.

答案1

得分: 0

尝试使用 @Type 注解,并将类型字段设置为 "uuid-char",问题得以解决。请查看下面的代码片段:

@Type(type = "uuid-char")
UUID productId;
英文:

Tried to use @Type annotation with type field sets to "uuid-char" and it solved the problem. Please find below snippet.

@Type(type = "uuid-char)
UUID productId;

huangapple
  • 本文由 发表于 2020年8月3日 16:30:47
  • 转载请务必保留本文链接:https://go.coder-hub.com/63226140.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定