Hibernate version: 3.1.3
Name and version of the database you are using: MySql 5.0
Hello,
I'm new to hibernate, so far everything works fine - except for one detail: i can't get on delete cascade to work.
i'm using hibernate annotations.
my entities look like this:
Code:
@Entity
@Name("address")
public class Address implements Serializable {
@Id @GeneratedValue
@NotNull
public Long getId() {
return id;
}
//more fields....
@OneToMany(cascade = {CascadeType.ALL })
@Cascade(value = {org.hibernate.annotations.CascadeType.ALL,
org.hibernate.annotations.CascadeType.DELETE_ORPHAN })
@JoinColumn(name = "address")
public Set<Communication> getCommunication() {
return communication;
}
}
@Entity
@Name("communication")
public class Communication {
@Id @GeneratedValue
@NotNull
public Long getId() {
return id;
}
//more fields....
@ManyToOne()
@JoinColumn(name="address", insertable=false, updatable=false)
public Address getAddress() {
return address;
}
}
everything works fine, except the sql statement is missing the "on delete cascade".
so when i try to delete an address, the corresponding communications are not delete but instead an error is raised...
What can I do?
thank you very much!