我遇到了hibernate连接问题。我有两个表,dbo.issues和dbo.comments,其中每个问题可以有多个与之关联的注释。在dbo.issues表中,ID表示为ISSUE-123456,而在注释表中,它们表示为123456,没有ISSUE-前缀。简化代码如下。
Issue.java
@Entity
@Table(name = "dbo.issues")
//And some named queries
public class Issue
{
@Id
@Column(name = "CallID")
private String id;
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy = "issue")
private List<IssueComment> comments;
//Getters and setters here
}
IssueComment.java
@Entity
@Table(name = "dbo.comments")
public class IssueComment implements Serializable
{
@Id
@Column(name = "issueid")
private String issueId;
@Column(name = "comment")
private String comment;
@ManyToOne
@JoinColumnOrFormula(formula=@JoinFormula(value="SUBSTR(CallID, 7, LEN(CallID))"))
private Issue issue;
//Getters and setters here
}
当我尝试运行查询时,出现错误:
com.microsoft.sqlserver.jdbc.SQLServerException:列名'issue_CallID'无效。
谁能看到我做错了什么?我只能对表格进行只读访问,因此我无法操纵它们以使我的生活更轻松!