基本上,我不断收到编译错误提示
“原因:org.hibernate.AnnotationException:从Ticket引用PlayingInScreen的外键具有错误的列数。应为3”
我不明白这是什么意思,过去3个小时我一直在努力工作,这让我感到困惑。
import java.io.Serializable
import javax.persistence.*
@Entity
@Table(name = "Ticket")
data class Ticket(
@Id @GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "TicketId")
val ticketId: Long = -1,
@Id
@ManyToOne
@JoinColumn(name = "ScreenId")
val screenId: PlayingInScreen,
@Id
@ManyToOne
@JoinColumn(name = "TheaterId")
val theaterId: PlayingInScreen,
@ManyToOne
@JoinColumn(name = "StartTime", nullable = false)
val startTime: PlayingInScreen,
@ManyToOne
@JoinColumn(name = "StaffId")
val staffId: Staff,
@Column(name = "Price", nullable = false)
val price: Double = 0.0,
@Id
@Column(name = "SellingTimeStamp")
val sellingTimeStamp: Long = 0) : Serializable
import java.io.Serializable
import javax.persistence.*
@Entity
@Table(name = "PlayingInScreen")
data class PlayingInScreen(
@Id
@ManyToOne
@JoinColumn(name = "ScreenId")
val screenId: Screen,
@Id
@ManyToOne
@JoinColumn(name = "TheaterId")
val theaterId: Screen,
@ManyToOne
@JoinColumn(name = "MovieId")
val movieId: Movie,
@Id
@Column(name = "StartTime", nullable = false)
val startTime: Long = 0) : Serializable {
@OneToMany(mappedBy = "startTime")
private val startTimes: Set<Ticket> = emptySet()
@OneToMany(mappedBy = "theaterId")
private val theaterIds: Set<Ticket> = emptySet()
@OneToMany(mappedBy = "screenId")
private val screenIds: Set<Ticket> = emptySet()
}
项目要求: 正在播放画面: ScreenId字符(8)Pk,Fk(屏幕) TheaterId Char(8)Pk,Fk(屏幕)
门票: TheaterId Char(8)Pk,Fk(PlayingInScreen) ScreenId字符(8)Pk,Fk(PlayingInScreen) 开始时间日期不为空,Fk(PlayingInScreen)