0

我在 OpenJPA 2.0 上有一个实体

@Entity
@Table(name = "os_wfentry")
@SequenceGenerator(name = "jwe_seq", sequenceName = "jwe_seq", initialValue = 10, allocationSize = 1)
public class JPAWorkflowEntry implements WorkflowEntry, Serializable {

    private static final long serialVersionUID = -755511983025049452L;

    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "jwe_seq")
    private long id;

    @Column(name = "name")
    private String workflowName;

    @Column(name = "state")
    private Integer workflowState;

    @Column(name = "version")
    private Integer version;

    @OneToMany(cascade = CascadeType.ALL, mappedBy = "entry")
    private final List<JPACurrentStep> currentSteps;

    @OneToMany(cascade = CascadeType.ALL, mappedBy = "entry")
    private final List<JPAHistoryStep> historySteps;

    public JPAWorkflowEntry() {
        currentSteps = new ArrayList<>();
        historySteps = new ArrayList<>();
    }

...在我插入的 JPACurrent 和 JPAHistory 步骤中:

@ManyToOne
    @Column(name = "entry_id")
    protected JPAWorkflowEntry entry;

都是正确的(理论上);但是当我尝试保存(或更新)一个新的 JPAWorkflowStore 实例时,有一个非空的(当前或历史)步骤列表,步骤属性列表在 db 上不是持久化的,它始终是一个空列表。你能帮助我吗??我究竟做错了什么??

4

1 回答 1

0

您需要为您的 JPACurrent 和 JPAHistory 指定 @JoinColumn(name = "id", nullable = false)。

你所做的是 @Column(name = "entry_id") 我没有看到 "entry_id" 映射到 JPAWorkflowEntry 中的任何列

于 2013-10-14T12:10:50.140 回答