Java – hibernate cascading delete does not work as expected
•
Java
I'm using hibernate 3 and trying to delete records in the database, and deletion doesn't work properly Pattern hibernate is opposing (in pseudocode):
create table Employer(
employer_id number(12) primary key,employer_name varchar2(50)
);
create table Employee(
employee_id number(12) primary key,employee_name varchar2(50),employer_id number(12) foreign key references employer.employer_id not null
);
create table Employee_Roles(
role_id number(12) primary key,employee_id number(12) foreign key references employee.employee_id not null,role varchar2(50)
);
My hibernate class mapping looks like:
@Entity
public class Employer{
@Id
@Column(name = "EMPLOYER_ID")
private long id;
@Column
private String name;
@OneToMany(targetEntity = Employee.class,fetch = FetchType.EAGER)
@JoinColumn(name = "employer_id")
@Cascade(CascadeType.ALL)
private Set
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码