01/10/2018, 17:44

Liên kết ba bảng

e có 3 bảng:
project:

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id_project")
private int idProject;


@Column(name = "id_project_detail")
private int id_project_detail;

@Column(name="id_room")
    private int id_room;
@Column(name = "name")
private String name;

@Column(name = "scale")
private String scale;

@Column(name = "image")
private String image;

@Column(name = "status")
private int status;


@Column(name = "acreage")
private String acreage;



@Column(name = "note")
private String note;

@Column(name = "owner")
private String owner;
@Column(name = "begin_date")
private String beginDate;
@Column(name = "end_date")
private String endDate;
@Column(name = "type")
private String type;
@Column(name = "image_list")
private String imageList;

@Column(name = "description")
@Transient
private ArrayList<String> imageListArray;

@OneToMany(mappedBy = "project")
private Set<Project> projects;

building

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id_building")
private int idBuilding;

@ManyToMany
@JoinColumn(name = "id_project",referencedColumnName = "tbl_building_ibfk3",updatable = false,nullable = false)
private Project projects;

@ManyToMany(targetEntity = Project.class)
@JoinColumn()

@Column(name = "id_sector")
private int idSector;
@Column(name = "name")
private String name;
@Column(name = "number_of_floor")
private int numberOfFloor;
@Column(name = "number_of_product")
private int numberOfProduct;
@Column(name = "direction")
private String direction;
@Column(name = "note")
private String note;
@Column(name = "status")
private int status;
@Column(name = "imageList")
private String imageList;
@Transient
private ArrayList<String> imageListArray;

apartment

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id_apartment")
private int id_apartment;

@ManyToMany
@JoinColumn(name = "id_building")
private Building building;

@Column(name = "id_apartment_type")
private int id_apartment_type;

@Column(name = "code")
private String code;

@Column(name = "name")
private String name;

@Column(name = "floor")
private int floor;

@Column(name = "sell_price")
private int sell_price;

@Column(name = "note")
private String note;

@Column(name = "sell_status")
private int sell_status;

@Column(name = "lock_status")
private String lock_status;

@Column(name = "image_location")
private String image_location;

em đặt liên kết ko được

Bài liên quan
0