Hibernate updatable = false不能处理子实体

时间:2017-10-12 14:22:42

标签: java spring hibernate spring-data

我正在尝试使用updatable = false

上的@JoinColumn(name = "customer_id", updatable = false)来阻止更新子类详细信息

具有子详细信息的父实体如下:

@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@JoinColumn(name = "customer_id", updatable = false)
@Fetch(FetchMode.SUBSELECT)
private List<CustomerAddress> customerAddressDetails;

下面给出了子实体:

@Entity
@Table(name = "customer_address")
public class CustomerAddress {
  @Id
  @GeneratedValue(strategy = GenerationType.IDENTITY)
  @Column(name = "customer_address_id")
  private int customerAddressId;
  @Column(name = "address")
  private String addressName;
  @Column(name = "street")
  private String street;
  @Column(name = "city")
  private String city;

  ....getter...setters...
}

我正在尝试更新客户实体,如下所示:

session.update(customerObj);

但仍然值正在数据库中更新任何提示吗?

0 个答案:

没有答案