列数必须与引用的主键相同

时间:2018-10-19 08:40:52

标签: hibernate spring-roo

我知道这个问题已经讨论了很多次了,但是我坚持这个错误。我正在将Spring Roo 1.3.2与hibernate一起使用,并且出现

错误
  

azure_cost_enterprise_account [azure_cost_root_account]))必须具有   与引用的主键相同的列数   (azure_cost_root_account [id_,id])

@RooJavaBean
@RooToString
@RooJpaActiveRecord
public class AzureCostEnterpriseAccount {

    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "azure_cost_enterprise_account_seq")
    @SequenceGenerator(name = "azure_cost_enterprise_account_seq", sequenceName = "azure_cost_enterprise_account_id_seq", allocationSize = 1)
    private Long id;

    @NotNull
    private Long createdAt;

    private Long updatedAt;

    @NotNull
    private Long enrollmentNumber;

    @NotNull
    @Column(columnDefinition = "text")
    private String enrollmentAccessKey;

    @OneToOne(cascade = CascadeType.ALL,fetch=FetchType.LAZY)
    private AzureCostRootAccount azureCostRootAccount;

    @OneToMany(cascade = CascadeType.ALL, mappedBy = "azureCostEnterpriseAccount", fetch = FetchType.LAZY)
    private Set<AzureCostTenant> azureCostTenants = new HashSet<>();


}

这是第二类,我正在尝试使它们之间形成一对一的双向关系。

@RooJavaBean
@RooToString
@RooJpaActiveRecord
public class AzureCostRootAccount {

    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "azure_cost_root_account_seq")
    @SequenceGenerator(name = "azure_cost_root_account_seq", sequenceName = "azure_cost_root_account_id_seq", allocationSize = 1)
    private Long id;

    @NotNull
    @Column(name = "name")
    private String accountName;

    @NotNull
    @Enumerated(EnumType.STRING)
    private AzureAccountType azureAccountType;

    @NotNull
    private Boolean isDeleted;

    @NotNull
    private Long createdAt;

    private Long modifiedAt;

    @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
    private Customer customer;

    @OneToOne(cascade = CascadeType.ALL, mappedBy = "azureCostRootAccount", fetch = FetchType.LAZY)
    private AzureCostEnterpriseAccount azureCostEnterpriseAccount;

    @OneToMany(cascade = CascadeType.ALL, mappedBy = "azureCostRootAccount", fetch = FetchType.LAZY)
    private Set<AzureCostSubscription> azureCostSubscriptions = new HashSet<>();

    @OneToMany(cascade = CascadeType.ALL, mappedBy = "azureCostRootAccount", fetch = FetchType.LAZY)
    private Set<AzureCostRootAccountAccess> azureCostRootAccountAccesses = new HashSet<>();


}

任何人都可以向我解释为什么我会收到此错误以及如何解决它。

0 个答案:

没有答案