Comic Sans MS Lover Comic Sans MS Lover - 5 months ago 19
Java Question

Hibernate - How to provide right mapping to integer type?

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?

Answer

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;