双向映射错误:无法确定类型

时间:2019-05-03 13:33:19

标签: java hibernate jpa

我正在尝试使用nRoomAllocationId在Room Transfer和Room Department Mapping类上实现多对一和一对多双向映射。

RoomTransfer类

@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)]

有人可以告诉我我在映射中做错了什么吗?

1 个答案:

答案 0 :(得分:0)

您的字段是Caused by: com.coxautodev.graphql.tools.SchemaClassScannerError: Expected a user-defined GraphQL scalar type with name 'Object' but found none!。 JPA规范不允许这样做:

  

类的实例变量必须是private,protected或   程序包可见性与字段访问或属性无关   使用访问。使用属性访问时,属性访问器   方法必须是公开的或受保护的。