-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37 from Tave12st-Backend-Study/minyoungsong
[Week3][Chapter6~7] Minyoung Song
- Loading branch information
Showing
23 changed files
with
438 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package hellojpa; | ||
|
||
import javax.persistence.DiscriminatorValue; | ||
import javax.persistence.Entity; | ||
|
||
@Entity | ||
@DiscriminatorValue("A") | ||
public class Album extends Item{ | ||
|
||
private String artist; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package hellojpa; | ||
|
||
import javax.persistence.MappedSuperclass; | ||
import java.time.LocalDateTime; | ||
|
||
@MappedSuperclass | ||
public abstract class BaseEntity { | ||
private String createdBy; | ||
private LocalDateTime createdDate; | ||
private String lastModifiedBy; | ||
private LocalDateTime lastModifiedDate; | ||
|
||
public String getCreatedBy() { | ||
return createdBy; | ||
} | ||
|
||
public void setCreatedBy(String createdBy) { | ||
this.createdBy = createdBy; | ||
} | ||
|
||
public LocalDateTime getCreatedDate() { | ||
return createdDate; | ||
} | ||
|
||
public void setCreatedDate(LocalDateTime createdDate) { | ||
this.createdDate = createdDate; | ||
} | ||
|
||
public String getLastModifiedBy() { | ||
return lastModifiedBy; | ||
} | ||
|
||
public void setLastModifiedBy(String lastModifiedBy) { | ||
this.lastModifiedBy = lastModifiedBy; | ||
} | ||
|
||
public LocalDateTime getLastModifiedDate() { | ||
return lastModifiedDate; | ||
} | ||
|
||
public void setLastModifiedDate(LocalDateTime lastModifiedDate) { | ||
this.lastModifiedDate = lastModifiedDate; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package hellojpa; | ||
|
||
import javax.persistence.DiscriminatorValue; | ||
import javax.persistence.Entity; | ||
|
||
@Entity | ||
@DiscriminatorValue("B") | ||
public class Book extends Item { | ||
private String author; | ||
private String isbn; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package hellojpa; | ||
|
||
import javax.persistence.*; | ||
|
||
@Entity | ||
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) | ||
public abstract class Item { | ||
|
||
@Id | ||
@GeneratedValue | ||
private Long id; | ||
|
||
private String name; | ||
private int price; | ||
|
||
public Long getId() { | ||
return id; | ||
} | ||
|
||
public void setId(Long id) { | ||
this.id = id; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public int getPrice() { | ||
return price; | ||
} | ||
|
||
public void setPrice(int price) { | ||
this.price = price; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package hellojpa; | ||
|
||
import javax.persistence.Entity; | ||
import javax.persistence.GeneratedValue; | ||
import javax.persistence.Id; | ||
import javax.persistence.OneToOne; | ||
|
||
@Entity | ||
public class Locker { | ||
|
||
@Id | ||
@GeneratedValue | ||
private Long id; | ||
|
||
private String name; | ||
|
||
@OneToOne(mappedBy = "locker") | ||
private Member member; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
송민영/ex1-hello-jpa/src/main/java/hellojpa/MemberProduct.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package hellojpa; | ||
|
||
import javax.persistence.*; | ||
import java.time.LocalDateTime; | ||
|
||
@Entity | ||
public class MemberProduct { | ||
@Id | ||
@GeneratedValue | ||
private Long id; | ||
|
||
@ManyToOne | ||
@JoinColumn(name = "MEMBER_ID") | ||
private Member member; | ||
|
||
@ManyToOne | ||
@JoinColumn(name = "PRODCUT_ID") | ||
private Product product; | ||
|
||
private int count; | ||
private int price; | ||
private LocalDateTime orderDateTime; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package hellojpa; | ||
|
||
import javax.persistence.DiscriminatorValue; | ||
import javax.persistence.Entity; | ||
|
||
@Entity | ||
@DiscriminatorValue("M") | ||
public class Movie extends Item{ | ||
private String director; | ||
private String actor; | ||
|
||
public String getDirector() { | ||
return director; | ||
} | ||
|
||
public void setDirector(String director) { | ||
this.director = director; | ||
} | ||
|
||
public String getActor() { | ||
return actor; | ||
} | ||
|
||
public void setActor(String actor) { | ||
this.actor = actor; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package hellojpa; | ||
|
||
import javax.persistence.*; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
@Entity | ||
public class Product { | ||
@Id | ||
@GeneratedValue | ||
private Long id; | ||
|
||
private String name; | ||
|
||
@OneToMany(mappedBy="product") | ||
private List<MemberProduct> memberProducts = new ArrayList<>(); | ||
|
||
public Long getId() { | ||
return id; | ||
} | ||
|
||
public void setId(Long id) { | ||
this.id = id; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
송민영/jpashop/src/main/java/jpabook/jpashop/domain/Album.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package jpabook.jpashop.domain; | ||
|
||
import javax.persistence.Entity; | ||
|
||
@Entity | ||
public class Album extends Item{ | ||
private String artist; | ||
private String etc; | ||
|
||
public String getArtist() { | ||
return artist; | ||
} | ||
|
||
public void setArtist(String artist) { | ||
this.artist = artist; | ||
} | ||
|
||
public String getEtc() { | ||
return etc; | ||
} | ||
|
||
public void setEtc(String etc) { | ||
this.etc = etc; | ||
} | ||
} |
Oops, something went wrong.