Hi
I have a mapping that says the cascade="none" for parentCategory property
but when I test it, I can't seem to prove cascade="none", it always
gets persisted into DB as below
E.g.
Mapping
Code:
<hibernate-mapping>
<class name="org.ecomfuse.model.Category"
table="category">
...
<many-to-one
name="parentCategory"
column="parent_category_id"
cascade="none"
outer-join="false">
</many-to-one>
...
</hibernate-mapping>
TestsCode:
public void testParentCategoryNoneCascade() throws Exception {
Category category = dao.getCategory(new Long(1));
Category parentCategory = dao.getCategory(new Long(4));
assertNull( category.getParentCategory());
category.setParentCategory(parentCategory);
dao.saveCategory(category);
hibernateTemplate.flush();
hibernateTemplate.clear();
Category retrievedCategory = dao.getCategory(new Long(1));
// I would have expected assert below to be null but apparently
// this is not the case
assertNotNull( retrievedCategory.getParentCategory());
}
Can someone show me the right test to prove that the parentCategory
end is not persisted to database due to cascade="none"?
Thanks,
Sam