Я создаю одну таблицу фидов, в которой сопоставление один-ко-многим с комментариями и отображение много-к-одному с таблицей пользователей.Но когда я аннотирую поле user_table в моей сущности каналов как @ManyToOne, я получаю сообщение об ошибке типа @OneToOne или @ManyToOne в xxx ссылается на неизвестную сущность: java .util.Set, но когда я аннотирую его с помощью @ManyToMany, оно не выбрасываетсялюбая ошибка и таблица создаются.Может кто-нибудь объяснить мне, почему
package com.incture.metrodata.entity;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
@Entity
@Getter
@Setter
@ToString
@Table(name = "FEEDS_DETAILS")
public class FeedsDo implements BaseDo {
/**
*
*/
private static final long serialVersionUID = -2035537433672391211L;
@Id
@Column(name = "FEED_ID")
private String feedId;
@Column(name = "BODY")
private String body;
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "CREATED_AT")
private Date createdAt;
@Column(name = "CREATED_BY")
private String createdBy;
@Column(name = "TITLE")
private String title;
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "UPDATED_AT")
private Date updatedAt;
@Column(name = "UPDATED_BY")
private String updatedBy;
@Column(name = "IS_DELETED")
private int isDeleted = 0;
@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@JoinTable(name = "FEEDS_USERS", joinColumns = { @JoinColumn(name = "FEED_ID")}, inverseJoinColumns = { @JoinColumn(name = "USER_ID") })
private Set<UserDetailsDo> user = new HashSet<UserDetailsDo>(0);
@OneToMany(targetEntity = CommentsDo.class, fetch = FetchType.EAGER, cascade = CascadeType.ALL)
private List<CommentsDo> comments;
@Override
public Object getPrimaryKey()
{
return feedId;
}
}
package com.incture.metrodata.entity;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
@Entity
@Table(name = "COMMENTS")
public class CommentsDo implements BaseDo {
/**
*
*/
private static final long serialVersionUID = 5180603287069572120L;
@Id
@Column(name = "COMMENT_ID")
@GeneratedValue(strategy = GenerationType.AUTO)
private long commentId;
@Lob
private String comment;
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "CREATED_AT")
private Date createdAt;
@Column(name = "CREATED_BY")
private String createdBy;
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "UPDATED_AT")
private Date updatedAt;
@Column(name = "IS_DELETED")
private int isDeleted=0;
@Override
public Object getPrimaryKey() {
return commentId;
}
}
package com.incture.metrodata.entity;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.Lob;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import org.hibernate.annotations.ColumnDefault;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.Where;
import lombok.Data;
import lombok.ToString;
@Entity
@Data
@ToString
@Table(name = "USER_DETAILS")
@DynamicUpdate(true)
@Where(clause = "DELETE = 0")
public class UserDetailsDo implements BaseDo {
private static final long serialVersionUID = 1L;
@Id
@Column(name = "USER_ID",length=50)
private String userId;
@Column(name = "FIRST_NAME",length=100)
private String firstName;
@Column(name = "LAST_NAME",length=100)
private String lastName;
//@Formula(value = " concat(FIRST_NAME, ' ', LAST_NAME) ")
@Column(name = "NAME",length=100)
private String name;
@ManyToOne(cascade = CascadeType.ALL,fetch = FetchType.EAGER)
private RoleDetailsDo role;
@Column(name = "TELEPHONE",length=50)
private String telephone;
@Column(name = "CREATED_BY",length=50)
private String createdBy;
@Column(name = "UPDATED_BY",length=50)
private String updatedBy;
@Column(name = "MOBILE_TOKEN")
@Lob
private String mobileToken;
@Column(name = "WEB_TOKEN")
@Lob
private String webToken;
@Column(name = "LONGITUDE")
private Double longitude;
@Column(name = "LATITUDE")
private Double latitude;
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "CREATED_DATE")
private Date createdDate;
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "CREATED_AT")
private Date createdAt;
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "UPDATED_AT")
private Date updateAt;
@Column(name = "EMAIL",length=100)
private String email;
@Column(name = "PARENT_ID",length=100)
private String parentId;
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "LAST_LOGIN_TIME")
private Date lastLogedIn;
@Column(name = "TRACK_FREQUENCY")
@ColumnDefault("'30'")
private Long trackFreq;
@ManyToMany(cascade = CascadeType.ALL,fetch = FetchType.EAGER)
@JoinTable(name = "USERS_WAREHOUSE_MAPPING", joinColumns = { @JoinColumn(name = "USER_ID") }, inverseJoinColumns = {
@JoinColumn(name = "WARE_HOUSE_ID") })
private Set<WareHouseDetailsDo> wareHouseDetails = new HashSet<WareHouseDetailsDo>(0);
@ManyToMany(cascade = CascadeType.ALL,fetch = FetchType.EAGER)
@JoinTable(name = "USERS_COURIER_MAPPING", joinColumns = { @JoinColumn(name = "USER_ID") }, inverseJoinColumns = {
@JoinColumn(name = "COURIER_ID") })
private Set<CourierDetailsDo> courierDetails = new HashSet<CourierDetailsDo>(0);
@Column(name = "DELETE")
@ColumnDefault("'0'")
private Integer deleted = 0;
public void setDeleted() {
this.deleted = 1;
}
@Override
public Object getPrimaryKey() {
return userId;
}
}