0

I have a small application (spring 4.0, jpa 2.1, hibernate 5.0.2) and had been using "old" java.util.Date* classes as well as java.sql.Date*. Now I wanted to use java.time instead and read that it would work with an AttributeConverter. Unfortunately this doesn't seem to work. The moment I try to read the database object with a timestamp (the doa has an equivalent of java.time.localdatetime) I get an exception. It seems the Converter isn't being used at all even though the annotation is there. I only have an applicationContext.xml and no persistence.xml so where would I tell jpa to use the Converter (if the annotation isn't enough)? How can I see that the AttributeConverter is picked up by jpa at all?

Thanks in advance, John.

user3411565
  • 125
  • 1
  • 9

1 Answers1

0

@Converter is available in JPA2.1 .

Try to change your dependency config:

    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-entitymanager</artifactId>
        <version>4.3.5.Final</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.data</groupId>
        <artifactId>spring-data-jpa</artifactId>
        <version>1.7.2.RELEASE</version>
        <type>jar</type>
        <scope>compile</scope>
    </dependency>

    <dependency>
        <groupId>org.hibernate.javax.persistence</groupId>
        <artifactId>hibernate-jpa-2.1-api</artifactId>
        <version>1.0.0.Final</version>
    </dependency>

    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>4.3.5.Final</version>
    </dependency>
Rino Han
  • 21
  • 3