Last active
March 9, 2017 16:08
-
-
Save anncode1/c567fdb7b7cb2d2b05d923d3207518e7 to your computer and use it in GitHub Desktop.
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
package com.ann.model; | |
import java.io.Serializable; | |
import java.util.ArrayList; | |
import java.util.List; | |
import javax.persistence.CascadeType; | |
import javax.persistence.Column; | |
import javax.persistence.Entity; | |
import javax.persistence.FetchType; | |
import javax.persistence.GeneratedValue; | |
import javax.persistence.GenerationType; | |
import javax.persistence.Id; | |
import javax.persistence.JoinColumn; | |
import javax.persistence.JoinTable; | |
import javax.persistence.ManyToMany; | |
import javax.persistence.OneToMany; | |
import javax.persistence.Table; | |
import org.hibernate.annotations.LazyCollection; | |
import org.hibernate.annotations.LazyCollectionOption; | |
import com.fasterxml.jackson.annotation.JsonBackReference; | |
import com.fasterxml.jackson.annotation.JsonIgnore; | |
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | |
import com.fasterxml.jackson.annotation.JsonManagedReference; | |
@Entity | |
@Table(name="teacher") | |
public class Teacher implements Serializable { | |
private Long idTeacher; | |
private String name; | |
private String avatar; | |
private List<TeacherSocialMedia> teacherSocialMedias = new ArrayList<TeacherSocialMedia>(); | |
private List<Course> courses; | |
public Teacher() { | |
super(); | |
} | |
public Teacher(Long idTeqcher) { | |
super(); | |
this.idTeacher = idTeacher; | |
} | |
public Teacher(String name, String avatar, List<TeacherSocialMedia> teacherSocialMedias) { | |
super(); | |
this.name = name; | |
this.avatar = avatar; | |
this.teacherSocialMedias = teacherSocialMedias; | |
} | |
@Id | |
@Column(name="id_teacher") | |
@GeneratedValue(strategy=GenerationType.IDENTITY) | |
public Long getIdTeacher() { | |
return idTeacher; | |
} | |
public void setIdTeacher(Long idTeacher) { | |
this.idTeacher = idTeacher; | |
} | |
@Column(name="name") | |
public String getName() { | |
return name; | |
} | |
public void setName(String name) { | |
this.name = name; | |
} | |
@Column(name="avatar") | |
public String getAvatar() { | |
return avatar; | |
} | |
public void setAvatar(String avatar) { | |
this.avatar = avatar; | |
} | |
// @OneToMany(fetch = FetchType.EAGER)//, mappedBy = "pk.teacher", cascade=CascadeType.ALL) | |
// @JsonIgnore | |
// @JoinTable(name="teacher_social_media",joinColumns=@JoinColumn(name="id_teacher")) | |
@OneToMany(fetch = FetchType.EAGER) | |
@JoinColumn(name="id_teacher") | |
public List<TeacherSocialMedia> getTeacherSocialMedias() { | |
return teacherSocialMedias; | |
} | |
public void setTeacherSocialMedias(List<TeacherSocialMedia> teacherSocialMedias) { | |
this.teacherSocialMedias = teacherSocialMedias; | |
} | |
@OneToMany(mappedBy="teacher") | |
@JsonIgnore | |
public List<Course> getCourses() { | |
return courses; | |
} | |
public void setCourses(List<Course> courses) { | |
this.courses = courses; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment