Coder Social home page Coder Social logo

til's Introduction

Hello 😎

til's People

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

til's Issues

JPA 고급 매핑

JPA 고급 매핑

출처 : 자바 ORM 표준 JPA 프로그래밍 7장 JPA 시작(김영한 저)

JAVA `Optional.orElseGet` 올바르게 사용하기

Optional.orElseGet 올바르게 사용하기

  • 흔하게 볼 수 있는 회원가입 로직으로, 만약 기존에 가입된 유저가 없으면 새롭게 가입 시키는 로직인데
  • 잘못된 코드고 이렇게 하면 원하는대로 동작하지 않을 수 있다 🤔
User user = userRepository.findById(userInfo.getId()).orElse(signUpUser(userInfo));

It’s not CI, it’s just CI theatre

It’s not CI, it’s just CI theatre

https://twitter.com/martinfowler/status/868141120332730369

스크린샷 2022-08-01 오후 10 14 50

최근 ThoughtWorks tech radar는 기술 조직에서 사용하는 안티패턴인 "CI Theatre(극장)" 운영을 보류할 것을 권고했습니다. "CI 극장"은 실제로 CI를 수행하고 있지 않음에도 CI를 실행하는 듯한 환상을 줍니다. 나와 내 동료인 Emily Luke가 수행한 CI 연구를 바탕으로, CI 극장이 어떻게 생겼는지, 왜 이런 운영을 "보류" 할 것을 권장하는지, 그리고 CI 극장에 대항하는 방법에 대해 공유 드리겠습니다.

JPA Persistence Context

JPA Persistence Context

  • 엔티티 매니저가 엔티티를 저장하거나 조회하는 환경
  • 영속성 컨텍스트는 엔티티 매니저를 생성할 때 하나 생성됨

출처 : 자바 ORM 표준 JPA 프로그래밍 3장 JPA 시작(김영한 저)

Elasticsearch Full Text Quries

Elasticsearch(7.10.x) Full Text Quries

  • Elasticsearch에서 text 타입 필드에서 사용하는 쿼리들을 정리합니다
  • text 타입의 경우 keyword 타입과 다르게 전문 검색(Full Text Search)이 가능하며
  • 색인 전에 analyzer에 의한 분석이 발생합니다

JPA 엔티티 매핑

JPA 엔티티 매핑

출처 : 자바 ORM 표준 JPA 프로그래밍 4장 JPA 시작(김영한 저)

JPA `persistence.xml` 설정 정보를 통한 EntityManager 초기화

JPA persistence.xml 설정 정보 관리

  • JPA는 META-INF/persistence.xml 에서 필요한 설정 정보를 관리한다
  • JPA는 일반적으로 연결할 데이터베이스 당 하나의 영속성 유닛 을 등록하며 하나의 유닛당 고유한 이름을 부여한다
  • javax.persistence 로 시작하는 속성은 JPA 표준 속성으로 특정 구현체에 종속되지 않는 한편
    hibernate로 시작하는 속성은 하이버네이트 전용 속성을 의미한다
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence" version="2.1">
    <persistence-unit name="jpabook">
        <properties>
            <!-- 필수 속성 -->
            <property name="javax.persistence.jdbc.driver" value="org.h2.Driver"/>
            <property name="javax.persistence.jdbc.user" value="sa"/>
            <property name="javax.persistence.jdbc.password" value=""/>
            <property name="javax.persistence.jdbc.url" value="jdbc:h2:tcp://localhost/~/test"/>
            <property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect" />
            <!-- 옵션 -->
            <property name="hibernate.show_sql" value="true" />
            <property name="hibernate.format_sql" value="true" />
            <property name="hibernate.use_sql_comments" value="true" />
            <property name="hibernate.id.new_generator_mappings" value="true" />
            <!--<property name="hibernate.hbm2ddl.auto" value="create" />-->
        </properties>
    </persistence-unit>
</persistence>

출처 : 자바 ORM 표준 JPA 프로그래밍 2장 JPA 시작(김영한 저)

JPA 연관관계 매핑

JPA 연관관계 매핑

  • 출처 : 자바 ORM 표준 JPA 프로그래밍 5장~6장 JPA 시작(김영한 저)

Kotlin에서 Mockito 사용하여 테스트 할 때 유의할 점

Kotlin에서 Mockito 사용하여 테스트 할 때 유의할 점

  • Kotlin에서 Mocktio로 아래와 같이 ArgumentCaptor<T> 를 사용하여 테스트 코드를 작성했는데
data class Bucket(
    val id: Long = 0,
    val name: String = "",
    val url: String? = null
)

class BucketService {
    fun execute(bucket: Bucket) { ... }
}
class BucketTest {
    private lateinit var service: BucketService
    // ...
    @Test
    fun `버킷이 정상적으로 들어왔을 때 execute 함수를 테스트한다`() {
        // given & when 
        ...
        // then
        val captor = ArgumentCaptor.forClass(Bucket::class.java)
        verify(service, times(1)).execute(captor.capture())
        ...
    }
}
  • 이런 에러가 발생한다 🤔
java.lang.NullPointerException: captor.capture() must not be null
  at com.example.bucket.service.BucketTest.버킷이 정상적으로 들어왔을 때 execute 함수를 테스트한다 (BucketTest.kt:39)
  at java.util.ArrayList.forEach(ArrayList.java:1259)
  at java.util.ArrayList.forEach(ArrayList.java:1259)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.