Java – set hibernate ‘default cascade’ attribute globally
•
Java
I'm using annotated spring and hibernate I want to set the default cascade attribute for all classes 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 doesn't seem to work unless I explicitly define classes and attributes in the mapping file, because I'm dealing with comments elsewhere, which I really want to avoid Can default cascade be set globally without explicitly specifying properties?
Solution
You can set it on the configuration object Pseudo code
config = buildHibernateConfiguration(); for (ClassMap clazz : config.getClassMappings()) { clazz.getPropertyIterator(); }
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码