我正在尝试使用nRoomAllocationId
在房间传输和房间部门映射类上实现多对一和一对多双向映射。
房间转移类
@Entity
@Table(name="roomtransfer")
public class RoomTransfer implements Serializable {
@Id
@Column(name = "ntrans_id",columnDefinition="serial")
public Integer nTransId;
@Column(name="nroom_allocation_id")
public Integer nRoomAllocationId;
@NotNull
@Column(name="badd_transfer_bln")
public boolean bAddTransferBln=true;
@Column(name="dtrans_date")
public LocalDate dTransDate;
@Column(name="bis_active")
public boolean bIsActive=true;
@ManyToOne(optional = true)
@JoinColumn(name = "nroom_allocation_id", insertable = false, updatable = false)
public RoomDepartmentMapping roomDepartmentMapping;
RoomDepartmentMapping 类
@Entity
@Table(name="roomdepartmentmapping")
public class RoomDepartmentMapping implements Serializable{
@Id
@Column(name="nroom_allocation_id")
public Integer nRoomAllocationId;
@Column(name="nroom_id")
public Integer nRoomId;
@Column(name="bis_manual")
public Boolean bIsManual;
@ManyToOne(optional = true)
@JoinColumn(name = "nroom_id", insertable = false, updatable = false)
public Room room;
@OneToMany(mappedBy="roomDepartmentMapping", cascade = CascadeType.ALL)
public Set<RoomTransfer> roomTransfer;
错误
org.hibernate.MappingException: Could not determine type for: java.util.Set, at table: roomdepartmentmapping, for columns: [org.hibernate.mapping.Column(room_transfer)]
谁能告诉我我在映射时做错了什么?
最佳答案
您的字段是公开的
。 JPA 规范不允许这样做:
The instance variables of a class must be private, protected, or package visibility independent of whether field access or property access is used. When property access is used, the property accessor methods must be public or protected.
关于java - 双向映射错误: Could not determine type,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55970904/