Note that there are some explanatory texts on larger screens.

plurals
  1. POOverriding FactoryBean parameters with BeanFactoryPostProcessor
    primarykey
    data
    text
    <p>I need to override a nested property of an <code>AnnotationSessionFactoryBean</code> in a classic spring xml context. Since it is a nested property (the <code>HibernateProperties</code> one), I can't use <code>PropertyOverriderConfigurer</code></p> <p>The solution I have implemented is to load the context without refreshing it and add a <code>BeanFactoryPostProcessor</code> that retrieves the reference to the <code>FactoryBean</code> and change the property according to my requirement. However, the result is not what I have expected. It looks like the <code>FactoryBean</code> created the <code>Bean</code> before the <code>BeanFactoryPostProcessor</code> is executed, and the property is <strong>mutated</strong> on the <code>FactoryBean</code> but not on the already existing Bean, which has been created with the old value</p> <p>Is there a mechanism to programmatically override some <code>FactoryBean</code> properties <strong>before</strong> the bean is created? This is the <code>FactoryBean</code> generating the problem</p> <pre><code>&lt;bean id="startupSessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"&gt; &lt;property name="dataSource" ref="myDataSource"/&gt; &lt;property name="annotatedClasses"&gt; &lt;list&gt; &lt;value&gt;org.jfin.date.Period&lt;/value&gt; &lt;/list&gt; &lt;/property&gt; &lt;property name="hibernateProperties"&gt; &lt;props&gt; &lt;prop key="hibernate.dialect"&gt;org.hibernate.dialect.MySQLDialect&lt;/prop&gt; &lt;prop key="hibernate.cache.provider_class"&gt;org.hibernate.cache.NoCacheProvider&lt;/prop&gt; &lt;prop key="hibernate.jdbc.use_get_generated_keys"&gt;true&lt;/prop&gt; &lt;prop key="hibernate.cache.use_second_level_cache"&gt;false&lt;/prop&gt; &lt;prop key="hibernate.cache.use_query_cache"&gt;false&lt;/prop&gt; &lt;prop key="hibernate.hbm2ddl.auto"&gt;update&lt;/prop&gt; &lt;prop key="hibernate.connection.autocommit"&gt;false&lt;/prop&gt; &lt;/props&gt; &lt;/property&gt; &lt;/bean&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload