title: Spring & Hibernate: non transactional service methods
body: <p>I want my read methods not to use a transaction since this is just not needed at all, I only mark my create/update methods with @Transactional. But how do I do this? I have a pretty basic configuration of Spring with  etc... </p>
  
  <p><strong>SessionFactory</strong> is injected in my DAO, and in each method I call sessionFactory.<strong>getCurrentSession().doQueryStuff();</strong></p>
  
  <p>This, however results in this error:</p>
  
  <pre><code>org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here
  </code></pre>
  
  <p>If you need my Spring configuration:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:aop="http://www.springframework.org/schema/aop"
  xmlns:context="http://www.springframework.org/schema/context"
  xmlns:mvc="http://www.springframework.org/schema/mvc"
      xmlns:oxm="http://www.springframework.org/schema/oxm"
  xmlns:tx="http://www.springframework.org/schema/tx"
      xmlns:util="http://www.springframework.org/schema/util"
  xsi:schemaLocation="http://www.springframework.org/schema/beans
      http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
      http://www.springframework.org/schema/aop
      http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
      http://www.springframework.org/schema/context
      http://www.springframework.org/schema/context/spring-context-3.0.xsd
      http://www.springframework.org/schema/mvc
      http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
      http://www.springframework.org/schema/oxm
      http://www.springframework.org/schema/oxm/spring-oxm-3.0.xsd
      http://www.springframework.org/schema/tx
      http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
      http://www.springframework.org/schema/util
      http://www.springframework.org/schema/util/spring-util-3.0.xsd"&gt;
  
  &lt;context:annotation-config /&gt;
  &lt;context:component-scan base-package="be.howest.kidscalcula" /&gt;
  &lt;mvc:annotation-driven /&gt;
  
  &lt;bean id="viewResolver"
      class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt;
      &lt;property name="prefix"&gt;
          &lt;value&gt;/WEB-INF/views/&lt;/value&gt;
      &lt;/property&gt;
      &lt;property name="suffix"&gt;
          &lt;value&gt;.jsp&lt;/value&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  
  
  &lt;bean id="myDataSource"
      class="org.springframework.jdbc.datasource.DriverManagerDataSource"&gt;
      &lt;property name="driverClassName" value="com.mysql.jdbc.Driver" /&gt;
      &lt;property name="url" value="jdbc:mysql://localhost/kidscalcula" /&gt;
      &lt;property name="username" value="root" /&gt;
      &lt;property name="password" value="" /&gt;
  &lt;/bean&gt;
  
  &lt;bean class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"
      id="sessionFactory"&gt;
      &lt;property name="dataSource" ref="myDataSource" /&gt;
      &lt;property name="mappingResources"&gt;
          &lt;list&gt;
              &lt;value&gt;be/howest/kidscalcula/model/Foto.hbm.xml&lt;/value&gt;
              &lt;value&gt;be/howest/kidscalcula/model/Kindleerplanonderdeel.hbm.xml
              &lt;/value&gt;
              &lt;value&gt;be/howest/kidscalcula/model/Klas.hbm.xml&lt;/value&gt;
              &lt;value&gt;be/howest/kidscalcula/model/Leerkracht.hbm.xml&lt;/value&gt;
              &lt;value&gt;be/howest/kidscalcula/model/Leerling.hbm.xml&lt;/value&gt;
              &lt;value&gt;be/howest/kidscalcula/model/Leerplan.hbm.xml&lt;/value&gt;
              &lt;value&gt;be/howest/kidscalcula/model/LeerplanOefenreeks.hbm.xml
              &lt;/value&gt;
              &lt;value&gt;be/howest/kidscalcula/model/Leerplanonderdeel.hbm.xml&lt;/value&gt;
              &lt;value&gt;be/howest/kidscalcula/model/Niveau.hbm.xml&lt;/value&gt;
              &lt;value&gt;be/howest/kidscalcula/model/Oefenreeks.hbm.xml&lt;/value&gt;
              &lt;value&gt;be/howest/kidscalcula/model/Overgangsregel.hbm.xml&lt;/value&gt;
              &lt;value&gt;be/howest/kidscalcula/model/Rapport.hbm.xml&lt;/value&gt;
              &lt;value&gt;be/howest/kidscalcula/model/RapportLeerplanonderdeel.hbm.xml
              &lt;/value&gt;
              &lt;value&gt;be/howest/kidscalcula/model/Schooljaar.hbm.xml&lt;/value&gt;
              &lt;value&gt;be/howest/kidscalcula/model/Subonderdeel.hbm.xml&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.connection.pool_size"&gt;3&lt;/prop&gt;
              &lt;prop key="hibernate.show_sql"&gt;true&lt;/prop&gt;
              &lt;prop key="hibernate.format_sql"&gt;true&lt;/prop&gt;
              &lt;prop key="hibernate.use_sql_comments"&gt;true&lt;/prop&gt;
              &lt;prop key="hibernate.cache.use_second_level_cache"&gt;false&lt;/prop&gt;
  
          &lt;/props&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  
  &lt;!-- Configure the multipart resolver --&gt;
  &lt;bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"&gt;
      &lt;!-- one of the properties available; the maximum file size in bytes --&gt;
      &lt;property name="maxUploadSize" value="500000" /&gt;
  &lt;/bean&gt;
  
  
  &lt;!--
      Transaction manager for a single Hibernate SessionFactory (alternative
      to JTA)
  --&gt;
  &lt;bean id="transactionManager"
      class="org.springframework.orm.hibernate3.HibernateTransactionManager"&gt;
      &lt;property name="sessionFactory"&gt;
          &lt;ref bean="sessionFactory" /&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  
  &lt;tx:annotation-driven /&gt;
  </code></pre>
  
  <p></p>
  
  <p>Does this error have anything to do with the <strong>fact that Propagation is standard Required?</strong></p>