Spring data jpa 의 대량 조회 와 대량 삽입 및 상용 작업
4789 단어 자바springbootJPA
그래서 대량 삽입 을 고려 할 수 있 습 니 다.
사실 간단 해 요.기본 save()방법 만 사용 하면 돼 요.
현재 student 실체 클래스 가 있다 고 가정 합 니 다. 우 리 는 전체 학구 5000 명의 학생 들 의 정 보 를 한 번 에 삽입 해 야 한다.
4.567913.저 는 실체 류 에 주 해 를 달 지 않 았 습 니 다.실제 사용 할 때 스스로 주의 하 세 요.저 는 demo 만 쓰 고 실행 하지 않 았 습 니 다.
package com.chunying.boke.bean; /** * @author chunying */ public class Student { private Integer studentID; private String name; private Integer age; public Integer getStudentID() { return studentID; } public void setStudentID(Integer studentID) { this.studentID = studentID; } public String getName() { return name; } public void setName(String name) { this.name = name; } public Integer getAge() { return age; } public void setAge(Integer age) { this.age = age; } }
package com.chunying.boke.dao; import com.chunying.boke.bean.Student; import org.springframework.data.jpa.repository.JpaRepository; /** * @author chunying */ public interface StudentDao extends JpaRepository<Student, Integer> { }
대량 조회 에 대해 서 는 일반적인 JPA 작업 에 대응 하 는 방법 명 을 열거 합 니 다.
키워드
방법 이름
sql where 자구
And
findByNameAndPwd
where name= ? and pwd =?
Or
findByNameOrSex
where name= ? or sex=?
Is,Equals
findById,findByIdEquals
where id= ?
Between
findByIdBetween
where id between ? and ?
LessThan
findByIdLessThan
where id < ?
LessThanEquals
findByIdLessThanEquals
where id <= ?
GreaterThan
findByIdGreaterThan
where id > ?
GreaterThanEquals
findByIdGreaterThanEquals
where id > = ?
After
findByIdAfter
where id > ?
Before
findByIdBefore
where id < ?
IsNull
findByNameIsNull
where name is null
isNotNull,NotNull
findByNameNotNull
where name is not null
Like
findByNameLike
where name like ?
NotLike
findByNameNotLike
where name not like ?
StartingWith
findByNameStartingWith
where name like '?%'
EndingWith
findByNameEndingWith
where name like '%?'
Containing
findByNameContaining
where name like '%?%'
OrderBy
findByIdOrderByXDesc
where id=? order by x desc
Not
findByNameNot
where name <> ?
In
findByIdIn(Collection> c)
where id in (?)
NotIn
findByIdNotIn(Collection> c)
where id not in (?)
True
findByAaaTue
where aaa = true
False
findByAaaFalse
where aaa = false
IgnoreCase
findByNameIgnoreCase
where UPPER(name)=UPPER(?)
예:예 를 들 어 어떤 연령 대의 학생 들 을 대량으로 조회 해 야 한다.
List findByAgeIN(Coollection<> c);
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Is Eclipse IDE dying?In 2014 the Eclipse IDE is the leading development environment for Java with a market share of approximately 65%. but ac...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.