我想用 Play Framework 2.0 试用 Joda Time。所以我有一个名为 Release 的类:
@Entity
public class CommunicationLog extends Model {
private static final long serialVersionUID = 7846963755390952329L;
@Id
public int pk;
public Task taskRef;
public String comment;
@Type(type = "org.joda.time.contrib.hibernate.PersistentDateTime")
public DateTime createdDate;
public Person personRef;
}
在这篇文章 ( Persist Joda-time's DateTime via Hibernate) 中,我阅读了使用 joda-time-hibernate。所以我将它添加到我的 SBT 依赖项中,它会下载 jar 文件并将其添加到我的类路径中:
"joda-time" % "joda-time-hibernate" % "1.3"
但是问题依旧是@Type无法解析。我还需要将 org.hibernate.annotations 和 hibernate core 添加到我的类路径中吗?为什么这不是 JPA 2.0 的一部分?还是我错过了项目中的其他内容?
编辑 2012-05-07 :解决了
它在我添加以下依赖项时起作用:
"org.hibernate" % "hibernate-core" % "3.5.6-Final",
"org.hibernate" % "hibernate-annotations" % "3.5.6-Final",
"joda-time" % "joda-time-hibernate" % "1.3"
最佳答案
是的,您必须将 org.hibernate.annotations 添加到您的类路径中。
@Type
是Hibernate逻辑的一部分(Custom UserType),不是JPA的逻辑。
所以你必须混合使用 JPA 注释和 Hibernate 注释
关于jpa-2.0 - Play Framework 中的 JPA 2.0 和 @Type 注解,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10057919/