Announcement Announcement Module
Collapse
No announcement yet.
Creating a bean for hibernateProperties Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Creating a bean for hibernateProperties

    Hello,

    I'd like to make reference to a bean for the hibernateProperties, in order to defnie them only once.
    How can I do that ?

    Code:
    <bean id="sessionFactory1" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    		<property name="dataSource">
    			<ref bean="dataSource"/>
    		</property>
    		<property name="hibernateProperties">
    			<ref bean="hibernateProperties" />
    		</property>
    		<property name="mappingResources">
    			<list>
    				<value></value>
    			</list>
    		</property>
    	</bean>
    What kind of bean should it be ?

    Thanks in advance.
    ________________________ _ _ _
    bgOnline

  • #2
    Try this:

    Code:
    <bean id="hibernateProperties" class="java.util.Properties">
        <constructor-arg index="0">
            <props>
            ...
            </props>
        </constructor-arg>
    </bean>
    Regards,
    Andreas

    Comment


    • #3
      Thanks a lot !

      It works perfect !

      Thanks a lot !!

      _____________________ _ _ _
      bgOnline

      Comment


      • #4
        Hi!

        I tried this solution, but I get a "org.hibernate.HibernateException: Hibernate Dialect must be explicitly set"
        Code:
           <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
              <property name="dataSource" ref="oracleDataSource"/>
              <property name="hibernateProperties" ref="oracleHibernateProperties">
             ....
         </bean>
        Code:
          <bean id="oracleHibernateProperties" class="java.util.Properties">
              <constructor-arg index="0">
                 <props>
                    <prop key="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</prop>
                 </props>
              </constructor-arg>
           </bean>
        If I use the following this works just fine:
        Code:
          <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
              <property name="dataSource" ref="oracleDataSource"/>
              <property name="hibernateProperties">
                 <props>
                      <prop key="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</prop>
                 </props>
              </property>
         </bean>
        Any ideas?

        TIA!


        -Kaj
        Last edited by kajh; Jul 5th, 2006, 05:57 AM.

        Comment

        Working...
        X