2016년 11월 14일 월요일

[자바교육,스프링교육,JPA교육추천_탑크리에듀][SQLQueryFactory,Querydsl강좌]insert/update/delete,배치쿼리예문,스프링JPA교육

[SQLQueryFactory,Querydsl강좌]insert/update/delete,배치쿼리예문,스프링JPA교육 

                //update 배치 쿼리 
SQLUpdateClause myUpdate = queryFactory.update(emp); 

myUpdate.set(emp.sal, 3000L).where(emp.empno.eq(1L)).addBatch(); 
myUpdate.set(emp.sal, 3100L).where(emp.empno.eq(2L)).addBatch(); 
rowaffected = myUpdate.execute(); 

System.out.println(rowaffected + "건 update 완료!"); 

//insert 배치쿼리 
SQLInsertClause myInsert = queryFactory.insert(emp); 
myInsert.columns(emp.ename, emp.job, emp.sal).values("7길동", "교수", 7777).addBatch(); 
myInsert.columns(emp.ename, emp.job, emp.sal).values("8길동", "교수", 8888).addBatch(); 
rowaffected = myInsert.execute(); 

System.out.println(rowaffected + "건 insert 완료!"); 

//delete 배치쿼리 
SQLDeleteClause myDelete = queryFactory.delete(emp); 
myDelete.where(emp.ename.eq("7길동")).addBatch(); 
myDelete.where(emp.ename.eq("8길동")).addBatch(); 
rowaffected = myDelete.execute(); 

System.out.println(rowaffected + "건 delete 완료!");

댓글 없음:

댓글 쓰기