73 lines
1.8 KiB
Java
Raw Normal View History

2019-11-15 16:52:21 +01:00
package at.technikumwien.movies;
import lombok.*;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.Calendar;
import java.util.List;
@Data
@NoArgsConstructor
@AllArgsConstructor
@Entity
@Table(name = "t_movies")
@NamedQueries({
@NamedQuery(
name = "Movies.selectAll",
query = "SELECT n FROM Movies n"
),
@NamedQuery(
name = "Movies.selectByTitle",
query = "SELECT n FROM Movies n WHERE n.title LIKE :title"
)
})
@XmlRootElement
public class Movies {
// TODO: XmlAttributes may need different names
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@XmlAttribute
private Long id;
@Column(length = 100, nullable = false)
@XmlAttribute
private String title;
@XmlAttribute
private String description;
@Column(nullable = false)
@XmlAttribute
private Genre genre;
@Column(nullable = false)
@XmlAttribute
private int length;
@Column(nullable = false)
@XmlAttribute
private int releaseyear;
@ManyToMany(fetch = FetchType.EAGER)
@JoinTable(
name = "t_movies_actors",
joinColumns = @JoinColumn(name = "fk_movies_id"),
inverseJoinColumns = @JoinColumn(name = "fk_actors_id"))
private List<Actors> actors;
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "fk_studios_id")
private Studios studio;
public Movies(String title, String description, Genre genre, int length, int releaseyear) {
this.title = title;
this.description = description;
this.genre = genre;
this.length = length;
this.releaseyear = releaseyear;
}
}