74 lines
1.7 KiB
Java
74 lines
1.7 KiB
Java
package at.technikumwien.movies;
|
|
|
|
import lombok.*;
|
|
|
|
import javax.persistence.*;
|
|
import javax.xml.bind.annotation.*;
|
|
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"
|
|
)
|
|
})
|
|
|
|
@XmlRootElement
|
|
public class Movie {
|
|
@Id
|
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
|
@XmlAttribute
|
|
private Long id;
|
|
|
|
@Column(length = 100, nullable = false)
|
|
@XmlAttribute
|
|
private String title;
|
|
|
|
@Column(length = 2048)
|
|
@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;
|
|
|
|
@ManyToOne(fetch = FetchType.EAGER)
|
|
@JoinColumn(name = "fk_studios_id")
|
|
@XmlElement
|
|
private Studio studio;
|
|
|
|
public Movie(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;
|
|
}
|
|
} |