I am trying to implement basic audit using Spring Data JPA. From this question, I learned that it is not yet possible to enable auditing using annotations. So I have the following applicationContext.xmlfile in src/main/resources:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jpa="http://www.springframework.org/schema/data/jpa"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/data/jpa
http://www.springframework.org/schema/data/jpa/spring-jpa.xsd">
<jpa:auditing />
</beans>
I added the file @ImportResources("classpath:/applicationContext.xml")to my Java configuration file.
In my AbstractEntity(which is @MappedSuperClass) I have the following:
@MappedSuperclass
public abstract class AbstractEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Version
private Integer version;
@CreatedDate
private Date createdDate;
@LastModifiedDate
private Date lastModifiedDate;
}
Where java.util.Dateit was imported. I also tried with JodaTime, but no change.
, , . @CreatedBy @LastModifiedBy, , AuditAware bean... , .
?