我有以下课程:
薄膜:
@Entity
@Table(name="film")
public class Film implements Serializable {
@Id
@Column(name="id")
private String fbId;
@Column(name="title")
private String title;
@Column(name="year")
private int year;
@Column(name="description")
private String description;
@ManyToMany
@JoinTable(
name="direction",
joinColumns={@JoinColumn(name="person", referencedColumnName="id")},
inverseJoinColumns={@JoinColumn(name="film", referencedColumnName="id")})
private Collection<Person> directors;
@ElementCollection
@CollectionTable(name="genre", joinColumns=@JoinColumn(name="film"))
@Column(name="id")
private Collection<String> genres;
@ElementCollection
@CollectionTable(name="release", joinColumns=@JoinColumn(name="film"))
@Column(name="id")
private Collection<Release> releases;
@ElementCollection
@CollectionTable(name="trailers", joinColumns=@JoinColumn(name="film"))
@Column(name="id")
private Collection<URL> trailers;
@OneToMany(mappedBy="film")
@MapKey(name="character")
private Map<String, Performance> performances;
}
性能:
@Entity
@Table(name="performance")
public class Performance implements Serializable {
@Id
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="id")
private Film film;
@Id
@Column(name="film_character")
private String character;
@OneToOne(fetch=FetchType.LAZY)
@JoinColumn(name="id")
private Person actor;
}
人:
@Entity
@Table(name="person")
public class Person implements Serializable {
@Id
@Column(name="id")
private String fbId;
@Column(name="first_name")
private String firstName;
@Column(name="last_name")
private String lastName;
private Collection<Performance> performances;
}
推出:
@Entity
@Table(name="release")
public class Release implements Serializable {
@Id
@Column(name="film")
private Film film;
@Column(name="release_date")
private Date releaseDate;
@Column(name="medium")
private String region;
@Column(name="region")
private String medium;
}
当我测试某些内容时,我收到以下错误,即使所有类都实现了Serializable
Caused by: org.hibernate.MappingException: Composite-id class must implement Serializable: sw.film.model.Performance