Hi, I am having a problem displaying my objects. I am using the implementation of JPA2 and Hibernate. I got tables with @ManyToMany annotation
http://img204.imageshack.us/img204/7558/przykladd.png
I displayed it with:
@Entity
@Table("employee")
class Employee {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@Column
private String name;
@ManyToMany
@JoinTable(name = "proj_emp",
joinColumns = @JoinColumn(name = "employee_id", referencedColumnName = "id"),
inverseJoinColumns = @JoinColumn(name = "project_id", referencedColumnName = "id"),
uniqueConstraints = @UniqueConstraint(columnNames = {"employee_id", "project_id"}))
private List<Project> projects; ...}
@Entity
@Table("project")
class Project {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@Column
private String name;
@Column
private Integer budget;
@ManyToMany(mappedBy = "projects")
private List<Employee> employees; ...}
Now I would like to remove the cascade from the proj_emp table when I delete records from Employee, but nothing from the Project table can be deleted.
What is the best way to get this?
Thanks Dawid
Dawid source
share