![](/img/trans.png)
[英]JPA AttributeConverter makes hibernate generate update statements on whole table in transaction
[英]Spring JPA Hibernate and AttributeConverter
我有一个小应用程序(spring 4.0,jpa 2.1,hibernate 5.0.2),并且一直在使用“旧的” java.util.Date *类以及java.sql.Date *。 现在我想使用java.time并读取它可以使用AttributeConverter。 不幸的是,这似乎不起作用。 当我尝试使用时间戳读取数据库对象的时候(DOA具有等效的java.time.localdatetime),我得到了一个异常。 即使有注释,似乎也没有使用Converter。 我只有一个applicationContext.xml,没有persistence.xml,所以我要告诉jpa在哪里使用Converter(如果注释不够的话)? 我怎样才能看到AttributeConverter被jpa接走了?
预先感谢约翰。
@Converter在JPA2.1中可用。
尝试更改依赖项配置:
<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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.