title: Can I use Spring Data JPA Auditing without the orm.xml file (using JavaConfig instead)?
body: <p>I'm trying to get Spring Data Auditing to work in my Spring 3.2.8 / Spring Data 1.5 / Hibernate 4 project.</p>
  
  <p>As per the <a href="http://docs.spring.io/spring-data/data-jpa/docs/1.5.x/reference/html/jpa.repositories.html#jpa.auditing">Spring Data Auditing docs</a>, I've added the <code>@CreatedBy</code>, etc annotations to my entities, created by <code>AuditorAware</code> implementation, and instantiated it from within my JavaConfig.  However, it never seems to fire.</p>
  
  <p>I find the docs a little confusing.  It appears that the JavaConfig entry replaces the xml  entry, but I am not sure.</p>
  
  <p>I don't currently have any <code>orm.xml</code> file in my application.  To be entirely honest, I'm not even sure where/how to configure it, or why I need it.  All my entities are using annotations.  I have tried adding @EntityListeners(AuditingEntityListener.class) to the entity, but that has not helped.</p>
  
  <p>My current entity manager is defined without a persistence.xml file:</p>
  
  <pre><code>    &lt;!--  entity manager --&gt;
      &lt;bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"&gt;
          &lt;property name="dataSource" ref="dataSource"/&gt;
          &lt;property name="jpaVendorAdapter" ref="hibernateJpaVendorAdapter"/&gt;
          &lt;property name="packagesToScan" value="com.ia.domain"/&gt;
          &lt;property name="jpaProperties"&gt;
              &lt;props&gt;
                  &lt;prop key="hibernate.dialect"&gt;org.hibernate.dialect.MySQL5InnoDBDialect&lt;/prop&gt;
                  &lt;prop key="hibernate.query.substitutions"&gt;true '1', false '0'&lt;/prop&gt;
                  &lt;prop key="hibernate.generate_statistics"&gt;true&lt;/prop&gt;
                  &lt;prop key="hibernate.show_sql"&gt;false&lt;/prop&gt;
                  &lt;prop key="hibernate.format_sql"&gt;true&lt;/prop&gt;
                  &lt;prop key="hibernate.hbm2ddl.auto"&gt;update&lt;/prop&gt;
                  &lt;prop key="hibernate.ejb.naming_strategy"&gt;org.hibernate.cfg.ImprovedNamingStrategy&lt;/prop&gt;
                  &lt;prop key="hibernate.connection.charSet"&gt;UTF-8&lt;/prop&gt;
              &lt;/props&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
  </code></pre>
  
  <p>JavaConfig:</p>
  
  <pre><code>@Configuration
  @EnableJpaAuditing
  public class AuditConfig {
      @Bean
      public AuditorAware&lt;User&gt; auditorProvider(){
          return new SpringSecurityAuditorAware();
      }
  }
  </code></pre>
  
  <p>Entity:</p>
  
  <pre><code>@EntityListeners({AuditingEntityListener.class})
  @Entity
  public class User
  {
  
    @TableGenerator(name="UUIDGenerator", pkColumnValue="user_id", table="uuid_generator", allocationSize=1)
    @Id
    @GeneratedValue(strategy=GenerationType.TABLE, generator="UUIDGenerator")
    @Column(name="id")
    private Long id;
  
    @NotNull
    private String username;
  
    @CreatedDate
    @NotNull
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name="created_date", nullable=false)
    private Date createdDate;
  
    @LastModifiedDate
    @NotNull
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name="last_modified_date", nullable=false)
    private Date lastModifiedDate;
  
    @CreatedBy
    @ManyToOne(fetch=FetchType.LAZY)
    @JoinColumn(name="created_by")
    private User createdBy;
  
    @LastModifiedBy
    @ManyToOne(fetch=FetchType.LAZY)
    @JoinColumn(name="last_modified_by")
    private User lastModifiedBy;
    private String password;
    private Boolean enabled;
  
  
  ...
  }
  </code></pre>
  
  <p>I've put a breakpoint in my <code>SpringSecurityAuditorAware</code> class but it is never being hit.</p>
  
  <p>Do I still need an orm.xml file?  How/where is this referenced from the EntityManager?</p>