// ObjectA many-to-one with ObjectB // In ObjectA // mappedBy 的值是在 ObjectB 中的 attribute @OneToMany(fetch = FetchType.LAZY, mappedBy = "objectA") public List<ObjectB> getObjectB() { return objectBs; } // In ObjectB @ManyToOne(fetch = FetchType.LAZY, cascade = { CascadeType.PERSIST, CascadeType.MERGE }) @JoinColumns({ @JoinColumn(name = "FIELD_X", referencedColumnName = "FIELD_X", insertable = false, updatable = false ) }) public ObjectA getObjectA() { return objectA; }
沒有留言:
張貼留言