gpt4 book ai didi

java - 双向映射错误: Could not determine type

转载 作者:行者123 更新时间:2023-12-02 06:01:45 28 4
gpt4 key购买 nike

我正在尝试使用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/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com