[스프링부트JPA강좌]Querydsl,오라클시퀀스(Sequence)예제
감사합니다.
@Override
public Long insertMyemp1(String ename, Long sal, String deptno) {
////////////////////////////////////////////////////////////////
// myemp1테이블에 insert, 오라클 시퀀스이용
// 시퀀스생성:create sequence seq_myemp1_empno start with 10000003
// select seq_myemp1_empno.nextval from dual;
// 시퀀스이름을 줄때 앞에스키마명까지 줘야한다. 아니면 ORA-02289 발생
//-------------------------------------------------------------
// insert into myemp1 (empno, ename, sal, deptno)
// values (test.seq_myemp1_empno, ?, ?, ?)
////////////////////////////////////////////////////////////////
Long cnt = queryFactory.insert(myemp1)
.columns(myemp1.empno, myemp1.ename, myemp1.sal, myemp1.deptno)
.values(SQL__EXPRESSION__s.nextval("test.seq_myemp1_empno"),ename,sal,deptno)
.execute();
return cnt;
}
------------------------------------------------------------------------
[로그]
10. insert into MYEMP1 (EMPNO, ENAME, SAL, DEPTNO)
values (test.seq_myemp1_empno.nextval, '오제이씨', 9999, '1')
20160304 21:14:54.194 [http-nio-8080-exec-7] INFO j.sqltiming - insert into MYEMP1 (EMPNO, ENAME, SAL, DEPTNO)
values (test.seq_myemp1_empno.nextval, '오제이씨', 9999, '1')
{executed in 255 msec}
감사합니다.
@Override
public Long insertMyemp1(String ename, Long sal, String deptno) {
////////////////////////////////////////////////////////////////
// myemp1테이블에 insert, 오라클 시퀀스이용
// 시퀀스생성:create sequence seq_myemp1_empno start with 10000003
// select seq_myemp1_empno.nextval from dual;
// 시퀀스이름을 줄때 앞에스키마명까지 줘야한다. 아니면 ORA-02289 발생
//-------------------------------------------------------------
// insert into myemp1 (empno, ename, sal, deptno)
// values (test.seq_myemp1_empno, ?, ?, ?)
////////////////////////////////////////////////////////////////
Long cnt = queryFactory.insert(myemp1)
.columns(myemp1.empno, myemp1.ename, myemp1.sal, myemp1.deptno)
.values(SQL__EXPRESSION__s.nextval("test.seq_myemp1_empno"),ename,sal,deptno)
.execute();
return cnt;
}
------------------------------------------------------------------------
[로그]
10. insert into MYEMP1 (EMPNO, ENAME, SAL, DEPTNO)
values (test.seq_myemp1_empno.nextval, '오제이씨', 9999, '1')
20160304 21:14:54.194 [http-nio-8080-exec-7] INFO j.sqltiming - insert into MYEMP1 (EMPNO, ENAME, SAL, DEPTNO)
values (test.seq_myemp1_empno.nextval, '오제이씨', 9999, '1')
{executed in 255 msec}
댓글 없음:
댓글 쓰기