티스토리 뷰
1. 단방향 Mapping: JPA의 가장 기본적인 Entity Mapping
@Entity
@Table( name="someEntity")
public class someEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long someEntityId;
private String name;
@OneToMany
@JoinColumn(name = "someEntityId")
private List<SourceEntity> sourceEntityList;
}
@Entity
@Table(name="sourceEntity")
public class SourceEntity {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private Long id;
private String name;
}
2. 양방향 Mapping: JPA의 가장 기본적인 Entity Mapping
@Entity
@Table( name="someEntity")
public class someEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String name;
@OneToMany(mappedBy = "someEntity", cascade = CascadeType.ALL, fetch = FetchType.EAGER, orphanRemoval = true)
private List<SourceEntity> sourceEntityList;
}
@Entity
@Table(name="sourceEntity")
public class SourceEntity {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private Long id;
private String name;
@ManyToOne
@JoinColumn(name = "someEntityId")
private SomeEntity someEntity;
}
'Programming > JPA' 카테고리의 다른 글
Join Table (0) | 2019.05.31 |
---|---|
복합키 Mapping (0) | 2019.05.30 |
Embedded Mapping (0) | 2019.05.29 |
Discriminate Mapping (0) | 2019.05.26 |
Query DSL, Criteria 설정 (0) | 2019.03.01 |
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- 복합키 Mapping
- Spring JDBC Template
- SmartLifecycle
- docker
- java generic
- Registrar
- Spring Registrar
- Query DSL
- Discriminate Mapping
- scikit-learn
- RetryTemplate
- DI
- Property
- Akka
- JPA
- guava
- Criteria
- Sprint RetryTemplate
- Join Table
- spring spel
- Spring
- java EqualsAndHashCode
- @Primary
- Embeddable Mapping
- Charles proxy
- Embedded Mapping
- JPA Criteria
- Mapping
- Typesafe Config
- java Equals
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
글 보관함