2

I have a java bean that creates an endpoint:

@Bean
public String endpoint() {
    return "jdbc" + "a" + "b" + "c";
}

And I want to use that endpoint in my SessionFactory Bean:

<bean id="SessionFactory"
          class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"
          parent="AbstractSessionFactory">
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.connection.url">endpoint</prop>
            </props>
        </property>
    </bean>

How do I wire this up so that I can use it this way?

PM 77-1
  • 12,933
  • 21
  • 68
  • 111
Oscar Courchaine
  • 346
  • 3
  • 14

1 Answers1

0

It isn't ideal but using "map" instead of "props" I was able to get this to work. You can see full details at the link at the bottom, but my new code is:

@Bean
public String endpoint() {
    return "jdbc" + "a" + "b" + "c";
}

<bean id="SessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"
      parent="AbstractSessionFactory">
    <property name="hibernateProperties">
        <map>
            <entry>
                <key>
                    <value>hibernate.connection.url</value>
                </key>
                <ref bean="endpoint"/>
            </entry>            
        </map>
    </property>
</bean>

http://forum.spring.io/forum/spring-projects/container/55849-referencing-collections-props

Oscar Courchaine
  • 346
  • 3
  • 14