Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 7th, 2012  |  syntax: None  |  size: 3.55 KB  |  hits: 18  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. HibernateInterceptor with spring 3.1 and hibernate 4.01
  2. <?xml version="1.0" encoding="UTF-8"?>
  3. <beans xmlns="http://www.springframework.org/schema/beans"
  4. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
  5. xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context"
  6. xmlns:jee="http://www.springframework.org/schema/jee" xmlns:p="http://www.springframework.org/schema/p"
  7. xmlns:util="http://www.springframework.org/schema/util"
  8. xsi:schemaLocation="
  9.     http://www.springframework.org/schema/beans
  10.     http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
  11.     http://www.springframework.org/schema/tx
  12.     http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
  13.     http://www.springframework.org/schema/aop
  14.     http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
  15.     http://www.springframework.org/schema/jms
  16.     http://www.springframework.org/schema/jms/spring-jms-3.0.xsd
  17.         http://www.springframework.org/schema/context
  18.         http://www.springframework.org/schema/context/spring-context-3.0.xsd
  19.         http://www.springframework.org/schema/jee
  20.         http://www.springframework.org/schema/jee/spring-jee-3.0.xsd
  21.         http://www.springframework.org/schema/util
  22.         http://www.springframework.org/schema/util/spring-util-3.0.xsd">
  23.  
  24. <bean id="someDao" class="org.springframework.aop.framework.ProxyFactoryBean"
  25.     p:target-ref="someDaoTarget" p:proxyInterfaces="com.xxxx.MediaDataDao"
  26.     p:interceptorNames="hibernateInterceptor" />
  27.  
  28. <bean id="someDaoTarget" class="com.xxxx.SomeDaoImpl"
  29.     p:sessionFactory-ref="sessionFactory" />
  30.  
  31. <tx:annotation-driven transaction-manager="transactionManager" />
  32.  
  33. <bean id="transactionManager"
  34. class="org.springframework.orm.hibernate4.HibernateTransactionManager">
  35. <property name="sessionFactory" ref="sessionFactory" />
  36. </bean>
  37.  
  38. <bean id="hibernateInterceptor"
  39.   class="org.springframework.orm.hibernate3.HibernateInterceptor"
  40.   p:sessionFactory-ref="sessionFactory" />
  41.  
  42. <bean id="sessionFactory"
  43.   class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"
  44.   destroy-method="destroy"
  45.   p:dataSource-ref="dataSource">
  46.   <property name="packagesToScan"
  47. value="com.xxxx" />
  48.   <property name="hibernateProperties" ref="hibernateProperties" />
  49.  </bean>
  50.  
  51. <util:properties id="hibernateProperties">
  52. <prop key="hibernate.hbm2dll.auto">update</prop>
  53. <prop key="hibernate.connection.autocommit">false</prop>
  54. <prop key="hibernate.show_sql">true</prop>
  55. <prop key="hibernate.format_sql">false</prop>
  56. <prop key="hibernate.jdbc.batch_size">500</prop>
  57. <prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>
  58. <prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>
  59. <prop key="javax.persistence.validation.mode">callback</prop>
  60. </util:properties>
  61.        
  62. Caused by: java.lang.NoSuchMethodError: org.hibernate.SessionFactory.openSession()Lorg/hibernate/classic/Session;
  63. at  org.springframework.orm.hibernate3.SessionFactoryUtils.doGetSession(SessionFactoryUtils.java:322)
  64. at org.springframework.orm.hibernate3.SessionFactoryUtils.getSession(SessionFactoryUtils.java:233)
  65. at org.springframework.orm.hibernate3.HibernateInterceptor.getSession(HibernateInterceptor.java:145)
  66. at org.springframework.orm.hibernate3.HibernateInterceptor.invoke(HibernateInterceptor.java:90)
  67. at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
  68. at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
  69. at $Proxy37.getAll(Unknown Source)