μŠ€ν”„λ§

μ˜μ†μ„± μ΄λž€? (JPA Persistence) JPA μ—μ„œμ˜ μ˜μ†μ„±μ€ Entityλ₯Ό 영ꡬ적으둜 μ €μž₯ν•΄μ£ΌλŠ” ν™˜κ²½μ„ 의미 μ˜μ†μ„± 전이(cascade) λž€? 사전적 μ •μ˜ : 'μž‘μ€ 폭포', '폭포처럼 흐λ₯Έλ‹€' λΌλŠ” 뜻 μ—”ν…Œν‹° μƒνƒœλ₯Ό λ³€κ²½ν•  λ•Œ, ν•΄λ‹Ή 엔티티와 μ—°κ΄€λœ μ—”ν‹°ν‹°μ˜ μƒνƒœ λ³€ν™”λ₯Ό μ „νŒŒμ‹œν‚€λŠ” μ˜΅μ…˜ μ΄λ•Œ, λΆ€λͺ¨λŠ” One에 ν•΄λ‹Ήν•˜κ³  μžμ‹μ€ Many에 ν•΄λ‹Ή EX ) Order μ—”ν‹°ν‹°κ°€ μ‚­μ œλ˜μ—ˆμ„ λ•Œ ν•΄λ‹Ή 엔티티와 μ—°κ΄€λ˜μ–΄ μžˆλŠ” OrderItem μ—”ν‹°ν‹°κ°€ ν•¨κ»˜ μ‚­μ œ λ˜κ±°λ‚˜, Order μ—”ν‹°ν‹°λ₯Ό μ €μž₯ ν•  λ•Œ Order 엔티티에 λ‹΄κ²¨μžˆλ˜ OrderItem μ—”ν‹°ν‹°λ₯Ό ν•œκΊΌλ²ˆμ— μ €μž₯ κ°€λŠ₯ πŸ™‹‍♀️ μƒνƒœκ°€ μ „νŒŒλ˜λŠ” λͺ¨μŠ΅μ„ 폭포가 흐λ₯΄λŠ” λͺ¨μŠ΅μœΌλ‘œ 상상 CASCADE μ’…λ₯˜ μ„€λͺ… PERSIST λΆ€λͺ¨ μ—”ν‹°ν‹°κ°€ μ˜μ†ν™”λ  λ•Œ, μžμ‹..
μ—°κ΄€ 관계 맀핑 μ’…λ₯˜ μΌλŒ€μΌ(1:1) → @OneToOne μΌλŒ€λ‹€(1:N) → @OneToMany λ‹€λŒ€μΌ(N:1) → @ManyToOne λ‹€λŒ€λ‹€(N:N) → @ManyToMany μ—°κ΄€ 관계 맀핑 λ°©ν–₯ DB 쀑심 섀계 ν…Œμ΄λΈ”μ—μ„œ κ΄€κ³„λŠ” 항상 μ–‘λ°©ν–₯ JPA 객체 지ν–₯ 쀑심 μ„€κ³„μ—μ„œλŠ” 단방ν–₯, μ–‘λ°©ν–₯ 쑴재 μΌλŒ€μΌ 단방ν–₯ λ§€ν•‘ν•˜κΈ° Cart → Member μž₯λ°”κ΅¬λ‹ˆ-νšŒμ› 맀핑 ν…ŒμŠ€νŠΈ @Autowired CartRepository cartRepository; @Autowired MemberRepository memberRepository; @Autowired MemberController memberController; @PersistenceContext EntityManager entityManager; priv..
ADMIN κ³„μ •λ§Œ μ ‘κ·Όν•  수 μžˆλ„λ‘ μ„€μ • πŸ™ μƒν’ˆ 등둝, μˆ˜μ •, μ‚­μ œ νŽ˜μ΄μ§€ λ“±λ“± CustomAuththenticationEntryPoint public class CustomAuthenticationEntryPoint implements AuthenticationEntryPoint { @Override public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException, ServletException { response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Unauthorized"..
μƒν’ˆ μ—”ν‹°ν‹° @Entity @Getter@Setter public class Item { @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "item_id") private Long id; private String itemName; private int price; private String itemDetail; private String type; @Enumerated(EnumType.STRING) private ItemSellStatus itemSellStatus; }ItemSellStatus ν’ˆμ ˆ/판맀 μƒνƒœλ₯Ό λ‚˜νƒ€λ‚΄λŠ” Enum Class μƒν’ˆ 이미지 application.properties μ„€μ • # 파일 ν•œ κ°œλ‹Ή μ΅œλŒ€ μ‚¬μ΄μ¦ˆ s..
νšŒμ› κ°€μž… ν™”λ©΄μœΌλ‘œ λΆ€ν„° λ„˜μ–΄μ˜€λŠ” κ°€μž…μ •λ³΄λ₯Ό 담을 DTO 객체 @Setter @NoArgsConstructor public class MemberFormDto { @NotBlank(message = "이름은 ν•„μˆ˜ μž…λ ₯ κ°’μž…λ‹ˆλ‹€.") private String name; @NotEmpty(message = "μ•„μ΄λ””λŠ” ν•„μˆ˜ μž…λ ₯ κ°’μž…λ‹ˆλ‹€.") private String memberId; @NotEmpty(message = "λΉ„λ°€λ²ˆν˜ΈλŠ” ν•„μˆ˜ μž…λ ₯ κ°’μž…λ‹ˆλ‹€.") @Length(min = 8, max = 16, message = "λΉ„λ°€λ²ˆν˜ΈλŠ” 8자 이상, 16자 μ΄ν•˜λ‘œ μž…λ ₯ν•΄μ£Όμ„Έμš”.") private String password; @NotEmpty(message = "μ£Όμ†ŒλŠ” ν•„μˆ˜ μž…λ ₯ κ°’μž…λ‹ˆλ‹€.") private ..
Builder νŒ¨ν„΄μ΄λž€? 볡합 객체의 생성 κ³Όμ •κ³Ό ν‘œν˜„ 방법을 λΆ„λ¦¬ν•˜μ—¬ λ™μΌν•œ 생성 μ ˆμ°¨μ—μ„œ μ„œλ‘œ λ‹€λ₯Έ ν‘œν˜„ κ²°κ³Όλ₯Ό λ§Œλ“€ 수 있게 ν•˜λŠ” νŒ¨ν„΄ μƒμ„±μž 인자둜 λ„ˆλ¬΄ λ§Žμ€ μΈμžκ°€ λ„˜κ²¨μ§€λŠ” 경우 μ–΄λ– ν•œ μΈμžκ°€ μ–΄λ– ν•œ 값을 λ‚˜νƒ€λ‚΄λŠ”μ§€ ν™•μΈν•˜κΈ° νž˜λ“¬ 또, μ–΄λ– ν•œ κ²½μš°μ—λŠ” νŠΉμ • 인자만 μƒμ„±ν•΄μ•Όν•˜λŠ” κ²½μš°κ°€ λ°œμƒν•¨ νŠΉμ • μΈμžμ— ν•΄λ‹Ή 값을 null둜 μ „λ‹¬ν•΄μ€˜μ•Ό ν•˜λŠ”λ°, μ΄λŠ” 가독성 μΈ‘λ©΄μ—μ„œ 맀우 쒋지 μ•ŠμŒ πŸ™ μ΄λŸ¬ν•œ 문제λ₯Ό ν•΄κ²°ν•˜κΈ° μœ„ν•΄μ„œ λΉŒλ”νŒ¨ν„΄μ„ μ‚¬μš©ν•  수 있음 μž₯점 ν•„μš”ν•œ λ°μ΄ν„°λ§Œ μ„€μ • κ°€λŠ₯ μœ μ—°μ„± 확보 κ°€λŠ₯ 가독성 μƒμŠΉ λΆˆλ³€μ„± 확보 κ°€λŠ₯
πŸš€ μ°Έκ³ ν•œ μ±…μ—μ„œλŠ” WebSecurityConfigureAdapterλ₯Ό 톡해 security configλ₯Ό override ν–ˆμ§€λ§Œ, μ‚¬μš©ν•˜κ³  μžˆλŠ” λ²„μ „μ—μ„œλŠ” 였λ₯˜ λ°œμƒ!! UserDetailService λ°μ΄ν„°λ² μ΄μŠ€μ—μ„œ νšŒμ› 정보λ₯Ό κ°€μ Έμ˜€λŠ” μΈν„°νŽ˜μ΄μŠ€ loadUserByUsername() λ©”μ„œλ“œκ°€ μ‘΄μž¬ν•˜λ©°, νšŒμ› 정보λ₯Ό μ‘°νšŒν•˜μ—¬ μ‚¬μš©μžμ˜ 정보와 κΆŒν™˜μ„ κ°–λŠ” UserDetail μΈν„°νŽ˜μ΄μŠ€ λ°˜ν™˜ UserDetail μŠ€ν”„λ§ μ‹œνλ¦¬ν‹°μ—μ„œ νšŒμ›μ˜ 정보λ₯Ό λ‹΄κΈ° μœ„ν•΄μ„œ μ‚¬μš©ν•˜λŠ” μΈν„°νŽ˜μ΄μŠ€ MemberService @RequiredArgsConstructor @Service @Transactional public class MemberService implements UserDetailsService { /** μƒλž΅ ..
Thymeleaf Layout Dialect Dependency μΆ”κ°€ implementation('nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect')1. header/sidebar/footer/layout 생성 2. main/main.controller 생성 3. ν™”λ©΄ ν”„λ‘œμ νŠΈμ—μ„œ κ³΅ν†΅μœΌλ‘œ μ‚¬μš©ν•  λ ˆμ΄μ•„μ›ƒ 생성 μ™„λ£Œ!
KIMHYEYUN
'μŠ€ν”„λ§' μΉ΄ν…Œκ³ λ¦¬μ˜ κΈ€ λͺ©λ‘ (3 Page)