I have a unidirectional OneToOne relation like
@Entity
public class Citizen
{
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
protected Long id;
@OneToOne(cascade = CascadeType.ALL)
protected FileEntity photo;
...getters and setters....
}
@Entity
public class FileEntity
{
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
protected Long id;
}
Then when I go to remove a Citizen object the following error appear:
org.postgresql.util.PSQLException: ERROR: update o delete on <> violates the foreign key fk_citizen_file_id in the table <>
Why this happen??