74 lines
1.7 KiB
Java
Raw Normal View History

2019-11-15 16:52:21 +01:00
package at.technikumwien.movies;
import lombok.*;
import javax.persistence.*;
2019-11-29 15:15:08 +01:00
import javax.xml.bind.annotation.*;
2019-11-15 16:52:21 +01:00
import java.util.List;
@Data
@NoArgsConstructor
@AllArgsConstructor
@Entity
@Table(name = "t_movies")
@NamedQueries({
@NamedQuery(
name = "Movies.selectAll",
query = "SELECT n FROM Movie n"
),
@NamedQuery(
name = "Movies.selectByTitle",
query = "SELECT n FROM Movie n WHERE n.title LIKE :title"
)
})
2019-11-15 16:52:21 +01:00
@XmlRootElement
public class Movie {
2019-11-15 16:52:21 +01:00
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@XmlAttribute
2019-11-15 16:52:21 +01:00
private Long id;
@Column(length = 100, nullable = false)
@XmlAttribute
private String title;
2019-11-26 15:27:02 +01:00
@Column(length = 2048)
2019-11-15 16:52:21 +01:00
@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"))
@XmlElementWrapper(name = "actors")
@XmlElement(name = "actor")
private List<Actor> actors;
2019-11-15 16:52:21 +01:00
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "fk_studios_id")
@XmlElement
private Studio studio;
2019-11-15 16:52:21 +01:00
public Movie(String title, String description, Genre genre, int length, int releaseyear) {
2019-11-15 16:52:21 +01:00
this.title = title;
this.description = description;
this.genre = genre;
this.length = length;
this.releaseyear = releaseyear;
}
}