playframework OneToMany @JoinTable 不支持

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

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 +
'}';
}
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值