我有两张桌子
@Entity
@Table(name = "publicSitePortfolioWorks")
public class PublicSitePortfolioWorks implements java.io.Serializable {
@Id
@Column(name = "id")
private Integer id;
@Column(name = "mainImage")
private FrameworkFiles frameworkFilesByMainImage;
@Column(name = "androidImage")
private FrameworkFiles frameworkFilesByAndroidImage;
@Column(name = "bigImage")
private FrameworkFiles frameworkFilesByBigImage;
@Column(name = "mainName")
private String mainName;
@Column(name = "androidName")
private String androidName;
@Column(name = "url")
private String url;
@Column(name = "shortText")
private String shortText;
@Column(name = "`fullText`")
private String fullText;
@Column(name = "linkedObjectNameLocal")
private String linkedObjectNameLocal;
@Column(name = "`sort`")
private Integer sort;
@Column(name = "active")
private Integer active;
@OneToMany
@JoinTable(
name = "framework_files",
joinColumns = {
@JoinColumn(
// table = "framework_files",
name = "linkedObjectName",
referencedColumnName = "linkedObjectNameLocal"),
@JoinColumn(
// table = "framework_files",
name = "linkedObjectId",
referencedColumnName = "id"
)
}
// , inverseJoinColumns = @JoinColumn(name = "linkedObjectName")
)
private Set<FrameworkFiles> filesLocal = new HashSet<FrameworkFiles>(0);
第二张表
@Entity
@Table(name = "framework_files")
public class FrameworkFiles implements java.io.Serializable {
@Id
@Column(name = "id")
private Integer id;
@Column(name = "fileName")
private String fileName;
@Column(name = "fileSize")
private Float fileSize;
@Column(name = "filePath")
private String filePath;
@Column(name = "fileUrl")
private String fileUrl;
@Column(name = "linkedObjectId")
private Integer linkedObjectId;
@Column(name = "linkedObjectName")
private String linkedObjectName;
@Column(name = "active")
private Integer active;
@Column(name = "uploadDate")
private Date uploadDate;
@Column(name = "uploadersIP")
private String uploadersIp;
@Column(name = "uploadersIPXFORWARDEDFOR")
private String uploadersIpxforwardedfor;
@Column(name = "userName")
private String userName;
当我开始申请时,我得到了例外:
Caused by: org.hibernate.MappingException: Foreign key (FK_hksv6kkf3cysf5ug30q575tg1:framework_files [filesLocal_id])) must have same number of columns as the referenced primary key (framework_files [linkedObjectName,linkedObjectId,filesLocal_id])
at org.hibernate.mapping.ForeignKey.alignColumns(ForeignKey.java:110)
请告知,如何解决此异常。
我已经在stackoverflow上看到了很多关于此Exception的主题,但我不明白,如何在我的代码中修复此错误。