Hibernate version:2.1.6
Hi. I have a one-to-many mapping between World and Country with cascade="all-delete-orphan". In Country exists a property with a unique="true" constrain (String identifier). When I use the cascade-save mechanism, no exception is thrown when the identifier already exists. When I save the object explicitly, it works as expected.
A bug???
Do I have to save all objects with session.save() to ensure data integrity?
Example:
Does NOT throw an exception
Code:
world = (World)s.load(World.class,world.getId(),LockMode.UPGRADE);
Country country = new Country();
country.setIdentifier(identifier);
world.addCountry(country);
Does throw an exceptionCode:
world = (World)s.load(World.class,world.getId(),LockMode.UPGRADE);
Country country = new Country();
country.setIdentifier(identifier);
world.addCountry(country);
s.save(country);