Alex
Alex

Reputation: 1131

Setting hibernate 'default-cascade' property globally

I'm using Spring and Hibernate with annotations. I want to set the default-cascade property for all classes like this in my mapping file:

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping default-cascade="all"/>

After some debugging it seems this doesn't work unless I define the classes and properties explicitly in the mapping file, and since I'm working with annotations everywhere else I'd really like to avoid that. Is it possible to set default-cascade globally without explicitly specifying properties?

Upvotes: 4

Views: 2284

Answers (1)

Firo
Firo

Reputation: 30813

you can set it on the configuration object. pseudocode

config = buildHibernateConfiguration();

for (ClassMap clazz : config.getClassMappings())
{
    clazz.getPropertyIterator();
}

Upvotes: 1

Related Questions