I'm wondering if CascadeType.DELETE_ORPHAN is supposed to work with one-to-one relationships. Below is some example code of what I'm trying to do.
Hibernate version: 3.1.1
Mapping documents: 3.1-beta8
Code:
Code:
@Entity
public class Dog extends DomainObject {
...
@OneToOne( mappedBy = "dog", cascade = CascadeType.ALL )
@Cascade( org.hibernate.annotations.CascadeType.DELETE_ORPHAN )
private CachedArticle cachedArticle;
...
}
@Entity
public class Collar extends DomainObject {
...
@OneToOne
private Dog dog;
...
}
Dog dog = dogDao.getDog( 1 );
Collar collar = dog.getCollar();
assertTrue( collar != null );
dog.setCollar( null );
dog = dogDao.saveDog( dog );
collar = collarDao.getCollar( collar.getId() );
assertTrue( collar == null );