title: Get is not valid without active transaction
body: <p>i have a trouble opening Hibernate transaction.</p>
  
  <p>This is the configuration:</p>
  
  <pre><code>    &lt;context:annotation-config /&gt;
      &lt;context:component-scan base-package="com.cinebot" /&gt;
      &lt;mvc:annotation-driven /&gt;
      &lt;bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"&gt;
          &lt;property name="dataSource" ref="dataSource" /&gt;
          &lt;property name="packagesToScan"&gt;
              &lt;list&gt;
                  &lt;value&gt;com.cinebot.db.entity&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.HSQLDialect&lt;/prop&gt;
                  &lt;prop key="hibernate.show_sql"&gt;true&lt;/prop&gt;
              &lt;/props&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
  
      &lt;bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager"&gt;
          &lt;property name="sessionFactory" ref="sessionFactory" /&gt;
      &lt;/bean&gt;
  
  &lt;tx:annotation-driven /&gt;
  </code></pre>
  
  <p>And this is the faulty code:</p>
  
  <pre><code>@Transactional
  public static &lt;T&gt; T get(Class&lt;T&gt; classe, Serializable id) throws Exception {
      if(id==null) return null;
      T obj = (T) HibernateUtil.getSessionFactory().getCurrentSession().get(classe, id);
      return obj;
  }
  </code></pre>
  
  <p>This is the exception:</p>
  
  <pre><code>org.hibernate.HibernateException: get is not valid without active transaction
  </code></pre>
  
  <p>This is an example entitiy:</p>
  
  <pre><code>package com.cinebot.db.entity;
  
  // Generated 3-lug-2012 10.31.04 by Hibernate Tools 3.4.0.CR1
  
  import javax.persistence.Column;
  import javax.persistence.Entity;
  import javax.persistence.Id;
  import javax.persistence.Table;
  
  /**
   * Dettagli generated by hbm2java
   */
  @Entity
  @Table(name = "dettagli", catalog = "cinebot")
  public class Dettagli implements java.io.Serializable {
  
      private static final long serialVersionUID = 1L;
      private String nome;
      private String valore;
  
      public Dettagli() {
      }
  
      public Dettagli(String nome) {
          this.nome = nome;
      }
  
      public Dettagli(String nome, String valore) {
          this.nome = nome;
          this.valore = valore;
      }
  
      @Id
      @Column(name = "nome", unique = true, nullable = false, length = 32)
      public String getNome() {
          return this.nome;
      }
  
      public void setNome(String nome) {
          this.nome = nome;
      }
  
      @Column(name = "valore", length = 65535)
      public String getValore() {
          return this.valore;
      }
  
      public void setValore(String valore) {
          this.valore = valore;
      }
  
  }
  </code></pre>
  
  <p>I can not understand why is not enought the @Transactional annotation to auto-open the transaction. What i missed?</p>
  
  <p>Thanks</p>