【问题标题】:JPA 2.0 and @Type annotation in Play FrameworkPlay 框架中的 JPA 2.0 和 @Type 注释
【发布时间】:2012-04-07 20:05:10
【问题描述】:

我想用 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 核心添加到我的类路径中吗?为什么这不是 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"

【问题讨论】:

    标签: jpa-2.0 jodatime playframework-2.0


    【解决方案1】:

    是的,您必须将 org.hibernate.annotations 添加到您的类路径中。
    @Type 是 Hibernate 逻辑(自定义用户类型)的一部分,它不是 JPA 的逻辑。
    所以你必须将 JPA 注释与 Hibernate 注释混合使用

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-03-31
      • 2012-02-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-06-16
      • 1970-01-01
      相关资源
      最近更新 更多