Hi,
After using Hibernate for a while, I had assumed that insertable = false and updatable = false where useful for supporting reuse of columns across fields. But I got into an argument this week end with someone saying that the JPA spec does not define how/if this is mandated.
Example:
@Entity
public class Company {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id = null;
private String name = null;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "company")
private Set<Employee> employees = new HashSet<Employee>();
[..]
}
@Entity
public class Employee {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id = null;
private String name = null;
@ManyToOne()
@JoinColumn(name = "COMPANY_ID")
private Company company = null;
// Reuse of the field for the FK id
@Column(name = "COMPANY_ID", insertable = false, updatable = false)
private Long companyId;
}
I went through the JPA 2.1 draft, can could not find anything specific to this topic.
Should this be clarified? Or was it discussed before I joined?
Best regards,
Nicolas Seyvet