250x250
Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | |||
| 5 | 6 | 7 | 8 | 9 | 10 | 11 |
| 12 | 13 | 14 | 15 | 16 | 17 | 18 |
| 19 | 20 | 21 | 22 | 23 | 24 | 25 |
| 26 | 27 | 28 | 29 | 30 |
Tags
- posgis
- hadoop #hdfs
- postgres
- mysql
- uuid
- QGIS
- Java
- spring
- JWT
- 1093
- insert into
- Spring Security
- Linux
- spring boot
- Failed to load ApplicationContext
- AuthenticationPrincipal
- Docker
- Kafka
- JPA
- RDB
- JSON Web Token
- postgresql
- nginx
- Maven
- #mojo
- Geoserver
- psycopg2
- sftp
- LazyInitializationException
- python
Archives
- Today
- Total
FOREST_CHOI's BLOG
org.h2.jdbc.JdbcSQLDataException: Hexadecimal string contains non-hex character 본문
프로그래밍/JPA
org.h2.jdbc.JdbcSQLDataException: Hexadecimal string contains non-hex character
Forest_Choi 2022. 9. 20. 23:51728x90
jpa 에서 PK를 uuid로 지정해주고싶었다.
인턴하면서, pk를 sequence로 진행했다가 sequence가 고갈나는 문제를 발견했기 때문이다.
일단 uuid를 pk로 지정해주려면 일반적으로 예제에서 나오는 것과 다르게 어노테이션을 지정해 주어야한다.
class example {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
}
이렇게 하는것이 일반적이다. 하지만
class example{
@Id
@GeneratedValue(generator = "uuid2")
@GenericGenerator(name = "uuid2", strategy = "uuid2")
@Column(columnDefinition = "BINARY(16)", name = "userId", nullable = false, unique = true)
private UUID userId;
}
이렇게 넣어주어야 uuid 값으로 들어간다.
내가 발생했던 오류는
org.h2.jdbc.JdbcSQLDataException: Hexadecimal string contains non-hex character
UUID 값이 들어가는데 String을 지정해 줘서 생긴 문제였다.
private String userid => private UUID userid
이렇게 해야한다.
728x90
'프로그래밍 > JPA' 카테고리의 다른 글
| @Embedded, @Embeddable (0) | 2022.10.20 |
|---|---|
| JPA? (0) | 2022.10.16 |
| data.sql / insert 구문 시 pk 안들어가는 문제 (0) | 2022.09.23 |
| 영속성 전이 - 삭제 (0) | 2022.08.01 |
| LazyInitializationException 예외 (feat.@AuthenticationPrincipal) (0) | 2022.07.18 |
Comments