어수선한 다람쥐 창고

  • 홈
  • 태그
  • 방명록

Entity 1

JPA Inheritance Mapping 하나의 테이블을 여러 엔티티로 분리하기

테이블은 하나지만 특정 type컬럼에 따라 논리적으로는 성격이 나뉘는 경우가 있다. 예를 들자면 우리집 반려동물 테이블에 고양이와 강아지가 함께 들어있는데 강아지만 최근 산책 정보를 갖고 있는 경우이다. 이럴 때, 부모 엔티티를 두고 각 타입별로 자식 엔티티를 만들어 Inheritance Mapping을 지어줄 수 있다. 분류 기준이 되는 컬럼은 Discriminator Column으로 표시해주면 된다. 아래 예시는 TYPE이라는 컬럼이 분류 기준인 경우이다. 사용할 TYPE 값 중 하나는 A이다. @Inheritance(strategy=InheritanceType.SINGLE_TABLE) @DiscriminatorColumn(name="type") @DiscriminatorValue("A") https..

software engineering/web 2022.01.10
1
더보기
프로필사진

도토리 줍는 중

  • 전체 (38)
    • today I thought (3)
    • software engineering (33)
      • ready queue (0)
      • introduction (0)
      • web (20)
      • network (1)
      • os (0)
      • database (4)
      • devops (5)
      • design pattern (0)
      • etc (3)
    • inspiration (2)
      • lesson (1)
      • activity (0)
      • art (0)
      • reading (1)

최근글과 인기글

  • 최근글
  • 인기글

최근댓글

Archives

Tag

JavaScript, ERR_UPLOAD_FILE_CHANGED, A component is changing a controlled input of type text to be uncontrolled., JPA, 애플❤️, AOP, Java, 파괴적인 명령어, ERROR: Maven JVM terminated unexpectedly with exit code 137, 스프링 만세, 쿼리 검색, query, REACT_APP_, 리액트, 안드로이드 왕초보, Spring, react.js, PostgreSQL, View 생성 쿼리, maven,

Copyright © Kakao Corp. All rights reserved.

티스토리툴바