hamvocke / spring-testing

A Spring Boot application with lots of test examples
https://www.martinfowler.com/articles/practical-test-pyramid.html
1.11k stars 439 forks source link

Fix PK type to no have this error : "Unknown integral data type for ids : java.lang.String" #7

Closed ghusta closed 5 years ago

ghusta commented 6 years ago

Problem occurs when saving a Person with JPA and Postgres, and using a sequence.

hamvocke commented 5 years ago

Fixed with the latest update.

chamanbharti commented 4 years ago

The issue causes due to String data type I have fixed it using below code

@Entity
public class Message {
//when we use id data type Long or Integer
//    @Id
//    @GeneratedValue(strategy = GenerationType.AUTO)
//    Long id;
    //when we use id data type String
    @Id @GeneratedValue(generator="system-uuid")
    @GenericGenerator(name="system-uuid", strategy = "uuid")
    String id;
    @Column(nullable = false)
    String text;
   //setter & getter
}

Id will be created as 4028818e72ad878b0172ad8791c40000 its length will be 32