💻
Albert's Til
GitHub
  • 매일매일 조금씩 성장하기
    • README
    • CS
      • Network
      • HTTP
        • NO-CACHE
      • 오류 코드
      • ORM 도구
      • Design Pattern
        • CQRS Pattern
          • Event Sourcing and CQRS pattern
        • Builder Pattern
    • DB
      • MySQL
        • Timeline
        • Pagination
        • Index
        • Database Performance Optimization Strategies
        • B+ tree
        • MySQL Connectors VS MySQL Shell(Scripting) VS MySQL Workbench
        • MySQL Storage Engine Architecture
      • Normalization & Denormalization
      • JPA
        • @Transactional
        • Why JPA?
        • About JPA
        • N+1 Issue
        • Index
        • ElementCollection&CollectionTable
        • orphanRemoval
        • CascadeType
        • Use Subselect
        • Dynamic Instance Creation
        • Paging
        • Order
        • Spefication
        • mappedBy
      • MongoDB
        • ObjectId
      • Why MySQL?
      • ACID properties of transactions
      • Between JPA and JDBC
      • Identifiers in Hibernate/JPA
    • Java
      • Jackson de/serialize
      • Collections.singletonList() vs List.of()
      • Manage dependencies in Gradle
      • Logging Level
      • Bean Validation
      • JVM Internals
        • Threads
          • Frame
        • Shared Between Threads
          • Classloader
            • Class Loader Hierarchy
            • Loading Linking Initialization
      • Java Collection Framework
      • Annotation
      • Generic
      • 디미터 법칙
    • Spring
      • Caching
      • Spring Integration Overview
        • ThreadPollTaskExecutor
        • Messaging Bridge
        • Channel Adapter
        • Poller
        • Configuration and @EnableIntegration
        • Message Endpoints
        • Message Channels
      • HATEOAS
      • @Autowired vs Constructor Dependency Injection
      • Spring Security
        • JWT 토큰 사용한 인가
        • OAuth 2 Login
        • OAuth 2 인증
        • 인가
        • 인증
        • PasswordEncoder
      • IoC Container
      • Filter,Interceptor,AOP,Argument Resolver
      • Spring Annotation
      • About Spring
    • Kafka
      • Error Channel
    • Infra
      • Scale Up || Scale Out
      • Docker
        • Dockerfile
        • Docker Hub Deploy
        • Command
      • Cloud 유형
        • Infrastructure as a Service
        • Platform as a Service
        • Software as a Service
      • 무중단 배포
        • 엔진엑스(Nginx)
      • 코드 자동 배포
        • Technical
      • AWS EC2
        • PEM(Privacy Enhanced Mail) 키
      • AWS RDS
      • AWS S3
    • CodeSquad
      • Spring Boot Project 1주차 회고
      • Spring Boot Project 2주차 회고
      • Spirng Boot Project 3주차 회고
      • Spring Boot Project 4주차 회고
    • Foody Moody 프로젝트
      • Query Performance Comparison
      • HeartCount Asynchronous Issue
      • DeferredResult
      • ResponseBodyEmitter
      • SseEmitter (Spring)
      • Server-Sent Events (SSE)
      • 기술 스택 적용 이유
      • NO-CACHE(HTTP)
      • Transactional
    • DDD
      • AggregateId
    • Test
      • RestAssured
    • Coding and Algorithmic Problems
      • 819. Most Common Word
      • 344. Reverse String
      • 125. Valid Palindrome
      • 937. Reorder Data in Log Files
    • Node
      • Async... Await...
      • Custom Transactional Decorator Challenger
    • Python
      • Python Basic Grammar
        • Comments and Input/Output
        • Variable
        • Data type
        • Operations and syntax
        • List,Tuple,Dictionary,Set
        • Function
        • Conditional statement
        • Loop
    • HTML
      • HTML Basic
      • HTML Basic Tags
      • HTML Form Tags
      • HTML Table Tags
    • CSS
      • CSS Basic
      • CSS Practice
Powered by GitBook
On this page
  • 사용 예시
  • 컬렉션 종류
  • 값 타입
  • 매핑 테이블
  • Join 컬럼
  • Fetch 전략
  • Table Name
  • 유니크 제약 조건
  • 기타 속성

Was this helpful?

  1. 매일매일 조금씩 성장하기
  2. DB
  3. JPA

ElementCollection&CollectionTable

엔티티와 분리된 일반적인 값 객체들을 매핑

@CollectionTable은 @ElementCollection과 함께 사용되는 어노테이션으로, 매핑된 값 객체의 데이터를 저장하기 위한 별도의 매핑 테이블을 정의하는 데 사용됩니다.@CollectionTable을 사용하여 매핑 테이블을 정의하면 @ElementCollection에 의해 매핑된 값 객체의 데이터가 해당 테이블에 저장됩니다

사용 예시

@ElementCollection
private List<String> emails;

컬렉션 종류

List, Set, Collection, Map

값 타입

기본적인 자바 데이터 타입이나 사용자 정의 값 객체를 값 타입으로 사용할 수 있습니다. 값 객체는 @Embeddable 어노테이션이 적용된 클래스여야 합니다.

매핑 테이블

매핑된 값 객체의 데이터를 저장하기 위한 별도의 매핑 테이블을 생성합니다. 기본적으로 매핑 테이블은 매핑 소유자(엔티티)의 테이블과 연결됩니다.

Join 컬럼

@CollectionTable 에서 joinColumns를 사용하여 외래 키 관계를 정의할 수 있습니다.

Fetch 전략

@ElementCollection기본적으로는 FetchType.EAGER로 설정되어 있지만, FetchType.LAZY로 설정하여 지연 로딩을 사용할 수도 있습니다.

Table Name

@CollectionTable의 name 속성을 사용하여 맹핑 테이블의 이름을 지정할 수 있다.

기본적으로는 소유자 엔티티의 이름과 컬렉션 속성의 이름을 조합하여 자동으로 테이블 이름이 생성된다.

유니크 제약 조건

@CollectionTable의 uniqueConstrains 속성을 사용하여 매핑 테이블에 유니크 제약 조건을 정의할 수 있다.

@UniqueConstraint 어노테이션을 사용하여 유니크 제약 조건의 이름, 컬럼 등을 설정할 수 있다.

기타 속성

Last updated 1 year ago

Was this helpful?