`
TRAMP_ZZY
  • 浏览: 133645 次
社区版块
存档分类
最新评论

playframework OneToMany @JoinTable 不支持

阅读更多

play framework(v2.3.7) 集成Eean,不支持@OneToMany 生成中间表。
这是Ebean 实现JPA 标准的一个BUG。参见:https://github.com/ebean-orm/avaje-ebeanorm/issues/123

package models;

import play.db.ebean.Model;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * Created by zhaoyu on 12/28/14.
 */
@Entity
@Table(name = "t_clientapp")
public class ClientAppDao extends Model {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    public Long id;

    @Column(nullable = false, unique = true)
    public String clientNum;

    @Column(nullable = false)
    public String clientName;

    @ManyToOne
    @JoinColumn(name = "developer_id")
    public DeveloperDao developer;

    public String clientServerUrl;
    public String clientInfoUrl;
    public String version;
    public Double price;

    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
    @JoinTable(
            name = "t_clientapp_photo",
            joinColumns = @JoinColumn(name = "client_id", referencedColumnName = "id"),
            inverseJoinColumns = @JoinColumn(name = "photo_id", referencedColumnName = "id")
    )
    public List<PhotoDao> photos = new ArrayList<PhotoDao>();

    @ElementCollection
    @CollectionTable(
            name = "t_clientapp_tag",
            joinColumns = @JoinColumn(name = "client_id", referencedColumnName = "id")
    )
    @Column(name = "tag")
    public List<String> tags;


    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
    @JoinTable(
            name = "t_clientapp_logo",
            joinColumns = @JoinColumn(name = "client_id", referencedColumnName = "id"),
            inverseJoinColumns = @JoinColumn(name = "logo_id", referencedColumnName = "id")
    )
    public List<LogoDao> logos;

    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
    @JoinTable(
            name = "t_clientapp_function",
            joinColumns = @JoinColumn(name = "client_id", referencedColumnName = "id"),
            inverseJoinColumns = @JoinColumn(name = "function_id", referencedColumnName = "id")
    )
    public List<FunctionDao> functions;

    public String description;
    public String size;
    public Long downloads;

    @Temporal(TemporalType.TIMESTAMP)
    public Date onShelf;

    @OneToOne
    @JoinColumn(name = "type_id")
    public AppTypeDao type;

    public static Finder<Long, ClientAppDao> find = new Finder<Long, ClientAppDao>(
            Long.class, ClientAppDao.class
    );

    public ClientAppDao() {}

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        ClientAppDao clientApp = (ClientAppDao) o;

        if (clientNum != null ? !clientNum.equals(clientApp.clientNum) : clientApp.clientNum != null) return false;
        if (id != null ? !id.equals(clientApp.id) : clientApp.id != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = id != null ? id.hashCode() : 0;
        result = 31 * result + (clientNum != null ? clientNum.hashCode() : 0);
        return result;
    }

    @Override
    public String toString() {
        return "ClientApp{" +
                "id=" + id +
                ", clientNum='" + clientNum + '\'' +
                ", clientName='" + clientName + '\'' +
                ", clientServerUrl='" + clientServerUrl + '\'' +
                ", clientInfoUrl='" + clientInfoUrl + '\'' +
                ", version='" + version + '\'' +
                ", price=" + price +
                ", description='" + description + '\'' +
                ", size='" + size + '\'' +
                ", downloads=" + downloads +
                ", onShelf=" + onShelf +
                '}';
    }
}


分享到:
评论

相关推荐

    Hibernate_Annotation关联映射

    通过@JoinTable批注定义关联表,该关联表包含了指回实体表的外键(通过@JoinTable.joinColoumns)以及指向目标实体表的外键(通过@JoinTable.inverseJoinColoumns) @Entity @Table(name="Test_TreeType") public class ...

    JPA 标注 JPA标签手册

    o @JoinTable • L o @Lob • M o @ManyToMany o @ManyToOne o @MapKey o @MappedSuperclass • N o @NamedNativeQueries o @NamedNativeQuery o @NamedQueries o @NamedQuery • O o @OneToMany o @OneToOne o @...

    hibernate对象三状态及OneToOne&OneToMany&ManyToMany

    hibernate对象三状态及OneToOne&OneToMany&ManyToMany讲解,代码示例,数据库示例!非常全面

    JPA_OneToMany学习教程

    JPA_OneToMany学习教程JPA_OneToMany学习教程JPA_OneToMany学习教程JPA_OneToMany学习教程

    HIBERNATE 一对多 onetomany

    基于HIBERNATE 操作表的关系练习例子

    onetomany-hibernate

    onetomany-hibernate在myeclipse下的使用开发hibernate程序

    Hibernate注释大全收藏

    这种策略支持双向的一对多关联,但不支持 IDENTIFY 生成器策略,因为ID必须在多个表间共享。一旦使用就不能使用AUTO和IDENTIFY生成器。 每个类层次结构一张表 @Entity @Inheritance(strategy=InheritanceType....

    demo-onetomany-nosql:与OneToMany关系中的MongoDB的Spring Data演示项目

    一对多Nosql演示与OneToMany关系中的MongoDB的Spring Data演示项目 该项目是我发表的文章的来源。 请以下文章的链接:

    ejb.rar_EJB onetomany_ejb

    EJB基本知识介绍。如OneToOne,OneToMany等经典实例推荐

    BOS 技术整理

    @ManyToMany 一方写 mappedBy 放弃外键维护、另一方 @JoinTable 维护中间表 收派标准修添加能实现 html 请求 后台处理 服务器端Service和DAO编写整合springdatajpa 业务层接口 修改 Action 代码调用 ...

    Hibernate注解

    * 5.identity 使用SQL Server和MySQL的自增字段,这个方法不能放到Oracle中,Oracle不支持自增字段,要设定sequence(MySQL和SQL Server中很常用)。等同于JPA中的IDENTITY * 例:@GeneratedValue(generator = ...

    JPA课程manyToMany OneToMany 等全部测试

    JPA课程manyToMany OneToMany 等全部测试 注解, 有注释

    Hibernate_Course

    Hibernate课程 在这个资料库中,我尝试学习Hibernate 话题 简单的结局 预先映射 @OneToOne @OneToMany @多多 提取类型 懒惰的 渴望的

    Hibernate one to many(many to one) 配置

    NULL 博文链接:https://fqh1987.iteye.com/blog/791845

    oneToMany-OneToOne-search.zip

    oneToMany-OneToOne-search,xml方式、注解方式实现一对一查询、一对多查询,、注解方式实现一对一查询、一对多查询、注解方式实现一对一查询、一对多查询

    Java中的OneToMany的使用方法

    主要介绍了Java中的OneToMany的使用方法,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧

    C#例子代码 A0622_EF_OneToMany

    C#例子代码 A0622_EF_OneToManyC#例子...A0622_EF_OneToManyC#例子代码 A0622_EF_OneToManyC#例子代码 A0622_EF_OneToManyC#例子代码 A0622_EF_OneToManyC#例子代码 A0622_EF_OneToManyC#例子代码 A0622_EF_OneToMany

    Hibernate- oneToMany using annotation

    NULL 博文链接:https://tgwall163.iteye.com/blog/1277750

    Hibernate-OneToMany-Advance-udemy

    “#跟踪狐狸”“#跟踪狐狸”“#跟踪狐狸”“#跟踪狐狸”“#跟踪狐狸”“#跟踪狐狸”“#跟踪狐狸”“#跟踪狐狸”“#跟踪狐狸”“#跟踪狐狸”

    spring_ioc_onetomany

    spring_ioc_onetomany

Global site tag (gtag.js) - Google Analytics