Java 日食“;cascade=CascadeType.REFRESH";不级联entityManager.refresh()
我有一个简单的JPA映射,除了刷新没有被级联到子实体之外,其他一切都可以正常工作 这是我的相关代码:Java 日食“;cascade=CascadeType.REFRESH";不级联entityManager.refresh(),java,jpa,eclipselink,Java,Jpa,Eclipselink,我有一个简单的JPA映射,除了刷新没有被级联到子实体之外,其他一切都可以正常工作 这是我的相关代码: @Entity @Table(name = "prospection") public class ProspectionImpl extends AbstractIdentifiedObject<Prospection> implements Prospection { @Id @GeneratedValue @Column(name = "id")
@Entity
@Table(name = "prospection")
public class ProspectionImpl extends AbstractIdentifiedObject<Prospection> implements Prospection {
@Id
@GeneratedValue
@Column(name = "id")
private Long id;
@OneToMany(targetEntity = ProspectionLocationImpl.class, fetch = FetchType.EAGER, cascade =
CascadeType.ALL, orphanRemoval = true)
@JoinColumn(name = "prospection_id")
@JoinFetch(JoinFetchType.OUTER)
private Collection<Location> locations = new ArrayList<Location>();
}
结果是一个刷新的ProspectionImpl
bean,但是相同的locations
集合包含空的城市信息(ID除外)。现在在我的测试中,我有一个非空的位置列表,因此我尝试手动执行以下操作:
entityManager.refresh(prospection.getLocations().iterator().next());
它运行良好,我的城市现在充满了数据库中的所有数据
我觉得我的“级联型.所有”并不是级联刷新。我尝试了cascade={CascadeType.ALL,CascadeType.REFRESH}
来显式设置刷新级联,但找不到任何级联刷新的内容
我做错什么了吗?
是否存在全局EclipseLink设置以无法刷新级联
谢谢你的帮助。你所做的似乎是合法的。我怀疑这是一个错误。这是一个错误,不幸的是,到今天为止没有回应。幸运的是,这不是一个坏的解决办法,以刷新孩子们。
entityManager.refresh(prospection);
entityManager.refresh(prospection.getLocations().iterator().next());