Hibernate的 - 如何提供正确的映射到整数类型? [英] Hibernate - How to provide right mapping to integer type?
问题描述
最后一个原因:列类型为x.clients的列类型错误。 Found:tinyint,expected:integer
我是这样映射的:
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Integer id;
我使用InnoDB创建列如下: id int NOT NULL UNIQUE AUTO_INCREMENT
这不应该好吗?为什么说他在找tinyint?
解决方案使用 @ Basic 为基本整数。您可以随时尝试将您的ID声明为Long。我通常总是使用Long作为我的ID。请参阅映射标识符特征:
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
I'm executing my maven build and it throws this exception:
Last cause: Wrong column type in x.clients for column type. Found: tinyint, expected: integer
I'm mapping like this:
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Integer id;
And I'm creating the column using InnoDB like this: id int NOT NULL UNIQUE AUTO_INCREMENT
Shouldn't this be ok? Why is it saying that he is finding tinyint?
Use @Basic for basic integers. You can always trying declaring your ID as a Long though. I usually always use Long for my IDs. See Mapping Identifier Properities:
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
这篇关于Hibernate的 - 如何提供正确的映射到整数类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!