Announcement Announcement Module
Collapse
No announcement yet.
How to properly write a LocalSessionFactoryBean with Hibernate4? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to properly write a LocalSessionFactoryBean with Hibernate4?

    I'm converting my project from Spring3 using Hibernate3 to using Hibernate4. I can't get my LocalSessionFactoryBean to work. I get BeanCreationException:

    Code:
    org.springframework.beans.NotWritablePropertyException: Invalid property 'exposeTransactionAwareSessionFactory' of bean class [org.springframework.orm.hibernate4.LocalSessionFactoryBean]: Bean property 'exposeTransactionAwareSessionFactory' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
    Here's what my LocalSessionFactoryBean looks like:
    Code:
          <bean id="mySessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
            <property name="configLocation" value="classpath:hibernate.cfg.xml" />
            <property name="exposeTransactionAwareSessionFactory" value="true"/> 
    
            <property name="mappingResources">
              <list>
                <value>com/mycompany/steps/model/PerEpdData.hbm.xml</value>
                <value>com/mycompany/steps/model/PerCompanyProperties.hbm.xml</value>
              </list>
            </property>
            
            <property name="hibernateProperties">
              <value>
                  hibernate.dialect=org.hibernate.dialect.Oracle10gDialect
                  hibernate.connection.autocommit=true
                  hibernate.current_session_context_class=thread
              </value>
            </property>
          </bean>
    This works with Hibernate3. Any ideas on a fix?

    Thanks,

    --Bob

  • #2
    The snippet you posted is for hibernate3 not hibernate4... The exception is pretty clear... There is no 'exposeTransactionAwareSessionFactory' property so remove it.

    Also if you use spring managed transactions the hibernate.current_session_context should be removed (unless you use JTA but the current setting breaks proper tx management).

    Comment


    • #3
      Originally posted by Marten Deinum View Post
      The snippet you posted is for hibernate3 not hibernate4... The exception is pretty clear... There is no 'exposeTransactionAwareSessionFactory' property so remove it.

      Also if you use spring managed transactions the hibernate.current_session_context should be removed (unless you use JTA but the current setting breaks proper tx management).
      Thanks Marten, that got me working again. I appreciate the help!

      --Bob

      Comment

      Working...
      X