Spring #15

김형우·2022년 3월 8일
0

Spring

목록 보기
16/19

22-03-08

스프링 / 하이브네이트, 마이바티스 / 오라클 사용가능자

스프링은 컨트롤러 만들어주는 라이브러리 개념

우리는 node.js => C와 M을 합쳐서 사용 (컨트롤러와 모델)

오늘은 저장소에 대한것 => Repository

기본 문법

  1. 이거 안됨
    : '==' 으로 String 비교 안된다
if(btn == "1개삭제") {

}
  1. '==' 으로 비교가능한것
    : int, long, char

Spring X MongoDB 문법

Keyword Sample Logical result
After 날짜 이후 findByBirthdateAfter(Date date) {"birthdate" : {"$gt" : date}}

Table 15. Supported keywords for query methods
Keyword Sample Logical result
After

findByBirthdateAfter(Date date)

{"birthdate" : {"$gt" : date}}

GreaterThan

findByAgeGreaterThan(int age)

{"age" : {"$gt" : age}}

GreaterThanEqual

findByAgeGreaterThanEqual(int age)

{"age" : {"$gte" : age}}

Before

findByBirthdateBefore(Date date)

{"birthdate" : {"$lt" : date}}

LessThan

findByAgeLessThan(int age)

{"age" : {"$lt" : age}}

LessThanEqual

findByAgeLessThanEqual(int age)

{"age" : {"$lte" : age}}

Between

findByAgeBetween(int from, int to)
findByAgeBetween(Range range)

{"age" : {"gt":from,"gt" : from, "lt" : to}}
lower / upper bounds ($gt / $gte & $lt / $lte) according to Range

In

findByAgeIn(Collection ages)

{"age" : {"$in" : [ages…​]}}

NotIn

findByAgeNotIn(Collection ages)

{"age" : {"$nin" : [ages…​]}}

IsNotNull, NotNull

findByFirstnameNotNull()

{"firstname" : {"$ne" : null}}

IsNull, Null

findByFirstnameNull()

{"firstname" : null}

Like, StartingWith, EndingWith

findByFirstnameLike(String name)

{"firstname" : name} (name as regex)

NotLike, IsNotLike

findByFirstnameNotLike(String name)

{"firstname" : { "$not" : name }} (name as regex)

Containing on String

findByFirstnameContaining(String name)

{"firstname" : name} (name as regex)

NotContaining on String

findByFirstnameNotContaining(String name)

{"firstname" : { "$not" : name}} (name as regex)

Containing on Collection

findByAddressesContaining(Address address)

{"addresses" : { "$in" : address}}

NotContaining on Collection

findByAddressesNotContaining(Address address)

{"addresses" : { "not" : { "in" : address}}}

Regex

findByFirstnameRegex(String firstname)

{"firstname" : {"$regex" : firstname }}

(No keyword)

findByFirstname(String name)

{"firstname" : name}

Not

findByFirstnameNot(String name)

{"firstname" : {"$ne" : name}}

Near

findByLocationNear(Point point)

{"location" : {"$near" : [x,y]}}

Near

findByLocationNear(Point point, Distance max)

{"location" : {"near":[x,y],"near" : [x,y], "maxDistance" : max}}

Near

findByLocationNear(Point point, Distance min, Distance max)

{"location" : {"near":[x,y],"near" : [x,y], "minDistance" : min, "$maxDistance" : max}}

Within

findByLocationWithin(Circle circle)

{"location" : {"geoWithin" : {"center" : [ [x, y], distance]}}}

Within

findByLocationWithin(Box box)

{"location" : {"geoWithin" : {"box" : [ [x1, y1], x2, y2]}}}

IsTrue, True

findByActiveIsTrue()

{"active" : true}

IsFalse, False

findByActiveIsFalse()

{"active" : false}

Exists

findByLocationExists(boolean exists)

{"location" : {"$exists" : exists }}

profile
The best

0개의 댓글