我试图让 Jadira、Hibernate 4 和 JSR-310 一起工作,但我遇到了一个非常奇怪的异常,我无法通过扫描网络找到任何信息。
POM 元素(与 Jadira/Joda 相关)
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.1</version>
</dependency>
<dependency>
<groupId>org.jadira.usertype</groupId>
<artifactId>usertype.core</artifactId>
<version>3.1.0.CR2</version>
</dependency>
<dependency>
<groupId>org.jadira.usertype</groupId>
<artifactId>usertype.extended</artifactId>
<version>3.1.0.CR2</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-testing</artifactId>
<version>${hibernate.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>${spring.framework.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>${hibernate.version}</version>
</dependency>
这是我的测试代码:
@Entity
@Table(name = "BUSINESS_DATES")
@BizDateValidatorI
public class BizDate {
@Id
@Column(name="BIZ_DATE_PK")
private int bizDatePk = -1;
@Column(name="BIZ_DATE")
@Type(type="org.jadira.usertype.dateandtime.joda.jsr310.PersistentLocalDate")
@NotNull
private LocalDate bizDate;
@Column(name="BIZ_DATE_TYPE")
@Enumerated(EnumType.STRING)
@NotNull
private BizDateTypeEnum bizDateTypeEnum;
@Column(name="DATE_DESC")
@NotBlank
@Length(min = 5, max = 100)
private String dateDesc;
@Column(name="START_TIME")
@Type(type="org.jadira.usertype.dateandtime.joda.jsr310.PersistentLocalDateTime")
private LocalDateTime startTime;
@Column(name="END_TIME")
@Type(type="org.jadira.usertype.dateandtime.joda.jsr310.PersistentLocalDateTime")
private LocalDateTime endTime;
<<Omitted getters/setters>>
应用环境:
<description>Application Context for Core Utilities</description>
<tx:annotation-driven transaction-manager="transactionManager" />
<context:component-scan base-package="org.jc.utils" />
<jpa:repositories base-package="org.jc.utils" />
<jdbc:embedded-database id="dataSource" type="H2">
<jdbc:script location="classpath:/org/jc/utils/basetests/basetests.sql" />
</jdbc:embedded-database>
有谁知道为什么我不断收到 java.lang.TypeNotPresentException: Type org.threeten.bp.Duration 不存在异常?Threeten 并没有被 Maven 中的用户类型声明所吸引,而且关于它在用户类型中的作用并不多。
谢谢!
约翰