11-15 08:50
Recent Posts
Recent Comments
Tags
- Naver Cloud
- appetizer
- TSQL
- ํ์ด์๊ณต๋ชจ์
- ์จ์ผ๋ํ
- ํ์ด์ฌ
- python
- ํ๋ก๋ณด๋ ธ
- ์คํฝ๋ ํ
- Java
- API๋ง์ผํ๋ ์ด์ค
- ict๊ณต๋ชจ์
- DB
- JOBํ๊ณ
- RaspberryPi
- ICT
- ํ์ด์
- ์๋์ด๋ ธ
- ์ด๋ธ์
- ๋ฐ์ดํฐ๋ฒ ์ด์ค
- SQL
- ์คํฝ์ค๋น
- API MarketPlace ๊ธ๋ก๋ฒ ์ํฌํฐ์ฆ
- ICT๋ฉํ ๋ง
- ์๋ฐ
- linux
- DATABASE
- mysql
- ์กํ๊ณ
- Spring
- Today
- Total
miinsun
[JPA] ORACLE JPA ์ํ์ค ์์ฑ ์ ์ฉ / ORA-02289: ์ํ์ค๊ฐ ์กด์ฌํ์ง ์์ต๋๋ค ํด๊ฒฐ ๋ฐฉ๋ฒ ๋ณธ๋ฌธ
WebApp/Spring
[JPA] ORACLE JPA ์ํ์ค ์์ฑ ์ ์ฉ / ORA-02289: ์ํ์ค๊ฐ ์กด์ฌํ์ง ์์ต๋๋ค ํด๊ฒฐ ๋ฐฉ๋ฒ
miinsun 2022. 2. 5. 20:52
๐ ์์ธ : ์ค๋ผํด์ mySql๊ณผ ๋ค๋ฅด๊ฒ id ์๋ ์ฆ๊ฐ๊ฐ ๋ถ๊ฐํ๋ค.
๐ ํด๊ฒฐ ๋ฐฉ๋ฒ
JPA๋ฅผ ํตํด ์ํ์ค ์์ฑ๊ธฐ๋ฅผ ๋ง๋ค์ด์ @ID ๊ฐ์ ์ง์ ์ฃผ์ ํด์ฃผ์
1. DB์ ์ํ์ค ์์ฑ
CREATE SEQUENCE FOLDER_SEQ START WITH 1 INCREMENT BY 1;
2. ์ํ์ค ์์ฑ๊ธฐ ๋ง๋ค๊ธฐ
@SequenceGenerator(
name = "FOLDER_SEQ_GENERATOR"
, sequenceName = "FOLDER_SEQ"
, initialValue = 1
, allocationSize = 1
)
public class Folder implements Serializable{
...
}
3. ์ํ์ค ์ ์ฉ
@Id
@Column(name="folder_Id")
@GeneratedValue(
strategy = GenerationType.SEQUENCE
, generator = "FOLDER_SEQ_GENERATOR"
)
private int folderId;
๐ ์ ์ฒด ์ฝ๋
package com.dalc.one.domain;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@SuppressWarnings("serial")
@Entity
@Table(name="folder")
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@SequenceGenerator(
name = "FOLDER_SEQ_GENERATOR"
, sequenceName = "FOLDER_SEQ"
, initialValue = 1
, allocationSize = 1
)
public class Folder implements Serializable{
@Id
@Column(name="folder_Id")
@GeneratedValue(
strategy = GenerationType.SEQUENCE
, generator = "FOLDER_SEQ_GENERATOR"
)
private int folderId;
@Column(name="user_id")
private String userId;
@Column(name="folder_name")
private String folderName;
}
๐ ํด๊ฒฐ ์๋ฃ
'WebApp > Spring' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Spring] ๋ค์ด๋ฒ ๋ธ๋ก๊ทธ ๊ฒ์ API ์ฌ์ฉํ๊ธฐ (0) | 2022.02.18 |
---|---|
[Spring] API ํค ๊ด๋ฆฌํ๋ ๋ฐฉ๋ฒ (0) | 2022.02.18 |
[JPA] ๋ณตํฉํค ์ค์ (0) | 2022.02.04 |
[Spring] ํ๊ธ ํ๋ผ๋ฏธํฐ ๊นจ์ง ํด๊ฒฐ ๋ฐฉ๋ฒ (0) | 2022.02.03 |
[Spring] Spring Boot๋ฅผ ์ด์ฉํ ๋จ์ยทํตํฉ ํ ์คํธ (0) | 2022.01.13 |
Comments