본문 바로가기

WIL(What I Learned)

Entity에 무작위의 문자열을 id값으로 지정하기

https://stackoverflow.com/questions/47934661/generate-unpredictable-random-id-for-entity

 

Generate unpredictable random @Id for Entity

I have the following code. Because the @Id value is generated sequentially in my MariaDB, it's not safe: I need to expose it in the clients. That's why I want a unpredictable random @Id. How should I

stackoverflow.com

@GeneratedValue(generator = "uuid")
@GenericGenerator(name = "uuid", strategy = "uuid")
@Column(columnDefinition = "CHAR(32)")
@Id
private String id;

 

'WIL(What I Learned)' 카테고리의 다른 글

okky Spring IoC  (0) 2021.08.05
JPA에서 복수의 pk 지정하기  (0) 2021.07.22
TIL  (0) 2021.07.13
자바 ArrayList에서 요소의 수 세기  (0) 2021.07.13
Week I Learned  (0) 2021.07.11