Skip to content

Commit 7f3339a

Browse files
committed
spring-projects#45 - Removed Jadira user types in favor of new JPA 2.1 AttributeConverters.
We now activate the JSR-310 AttributeConverters shipped with Spring Data JPA 1.8. Removed the dependency to Jadira user types and switch to non-time-zoned Java 8 LocalDateTime. Original pull request: spring-projects#46.
1 parent e953f6d commit 7f3339a

File tree

3 files changed

+7
-16
lines changed

3 files changed

+7
-16
lines changed

jpa/java8/pom.xml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,10 @@
1313

1414
<dependencies>
1515

16-
<dependency>
17-
<groupId>org.jadira.usertype</groupId>
18-
<artifactId>usertype.extended</artifactId>
19-
<version>3.2.0.GA</version>
20-
</dependency>
21-
2216
<dependency>
2317
<groupId>org.springframework.data</groupId>
2418
<artifactId>spring-data-jpa</artifactId>
25-
<version>1.8.0.DATAJPA-650-SNAPSHOT</version>
19+
<version>1.8.0.BUILD-SNAPSHOT</version>
2620
</dependency>
2721

2822
<dependency>

jpa/java8/src/main/java/example/springdata/jpa/java8/AbstractEntity.java

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,12 @@
1515
*/
1616
package example.springdata.jpa.java8;
1717

18-
import java.time.ZonedDateTime;
18+
import java.time.LocalDateTime;
1919

2020
import javax.persistence.GeneratedValue;
2121
import javax.persistence.Id;
2222
import javax.persistence.MappedSuperclass;
2323

24-
import org.hibernate.annotations.Type;
2524
import org.springframework.data.annotation.CreatedDate;
2625
import org.springframework.data.annotation.LastModifiedDate;
2726

@@ -33,11 +32,6 @@ public class AbstractEntity {
3332

3433
@Id @GeneratedValue Long id;
3534

36-
@CreatedDate//
37-
@Type(type = "org.jadira.usertype.dateandtime.threeten.PersistentZonedDateTime")//
38-
ZonedDateTime createdDate;
39-
40-
@LastModifiedDate//
41-
@Type(type = "org.jadira.usertype.dateandtime.threeten.PersistentZonedDateTime")//
42-
ZonedDateTime modifiedDate;
35+
@CreatedDate LocalDateTime createdDate;
36+
@LastModifiedDate LocalDateTime modifiedDate;
4337
}

jpa/java8/src/main/java/example/springdata/jpa/java8/AuditingConfiguration.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,14 @@
1616
package example.springdata.jpa.java8;
1717

1818
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
19+
import org.springframework.boot.orm.jpa.EntityScan;
1920
import org.springframework.context.annotation.Configuration;
21+
import org.springframework.data.jpa.domain.support.Jsr310JpaConverters;
2022
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
2123

2224
@Configuration
2325
@EnableAutoConfiguration
26+
@EntityScan(basePackageClasses = { AuditingConfiguration.class, Jsr310JpaConverters.class })
2427
@EnableJpaAuditing
2528
class AuditingConfiguration {
2629

0 commit comments

Comments
 (0)