这是我的第一篇帖子,如果我有任何错误,请原谅我。
当我想查询(添加,编辑,删除)数据库时,我得到一个错误java.lang.IllegalStateExctive:在同步期间,通过未标记为级联PERSIST的关系找到了一个新对象。
相关表格包括赞助商和捐款。它们之间存在一对多的关系。以下课程:赞助商
@Entity
@Table(name = "SPONSORS")
@NamedQueries({
@NamedQuery(name = "Sponsors.findAll", query = "SELECT s FROM Sponsors s")})
public class Sponsors implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Basic(optional = false)
@Column(name = "SPONSORID")
private Short sponsorid;
@Basic(optional = false)
@Column(name = "NAME")
private String name;
@Basic(optional = false)
@Column(name = "SURNAME")
private String surname;
@Basic(optional = false)
@Column(name = "ADDRESS")
private String address;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "sponsorid")
private List<Donations> donationsList;
public Sponsors() {
}
public Sponsors(Short sponsorid) {
this.sponsorid = sponsorid;
}
public Sponsors(Short sponsorid, String name, String surname, String address) {
this.sponsorid = sponsorid;
this.name = name;
this.surname = surname;
this.address = address;
}
public Short getSponsorid() {
return sponsorid;
}
public void setSponsorid(Short sponsorid) {
this.sponsorid = sponsorid;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getSurname() {
return surname;
}
public void setSurname(String surname) {
this.surname = surname;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public List<Donations> getDonationsList() {
return donationsList;
}
public void setDonationsList(List<Donations> donationsList) {
this.donationsList = donationsList;
}
@Override
public int hashCode() {
int hash = 0;
hash += (sponsorid != null ? sponsorid.hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof Sponsors)) {
return false;
}
Sponsors other = (Sponsors) object;
if ((this.sponsorid == null && other.sponsorid != null) || (this.sponsorid != null && !this.sponsorid.equals(other.sponsorid))) {
return false;
}
return true;
}
@Override
public String toString() {
return "Pat.Sponsors[ sponsorid=" + sponsorid + " ]";
}
}
捐款:
@Entity
@Table(name = "DONATIONS")
@NamedQueries({
@NamedQuery(name = "Donations.findAll", query = "SELECT d FROM Donations d")})
public class Donations implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Basic(optional = false)
@Column(name = "DONATIONID")
private Short donationid;
@Basic(optional = false)
@Column(name = "DONATIONDATE")
@Temporal(TemporalType.DATE)
private Date donationdate;
// @Max(value=?) @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
@Column(name = "DONATIONAMOUNT")
private Double donationamount;
@JoinColumn(name = "SPONSORID", referencedColumnName = "SPONSORID")
@ManyToOne(optional = false)
private Sponsors sponsorid;
public Donations() {
}
public Donations(Short donationid) {
this.donationid = donationid;
}
public Donations(Short donationid, Date donationdate) {
this.donationid = donationid;
this.donationdate = donationdate;
}
public Short getDonationid() {
return donationid;
}
public void setDonationid(Short donationid) {
this.donationid = donationid;
}
public Date getDonationdate() {
return donationdate;
}
public void setDonationdate(Date donationdate) {
this.donationdate = donationdate;
}
public Double getDonationamount() {
return donationamount;
}
public void setDonationamount(Double donationamount) {
this.donationamount = donationamount;
}
public Sponsors getSponsorid() {
return sponsorid;
}
public void setSponsorid(Sponsors sponsorid) {
this.sponsorid = sponsorid;
}
@Override
public int hashCode() {
int hash = 0;
hash += (donationid != null ? donationid.hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof Donations)) {
return false;
}
Donations other = (Donations) object;
if ((this.donationid == null && other.donationid != null) || (this.donationid != null && !this.donationid.equals(other.donationid))) {
return false;
}
return true;
}
@Override
public String toString() {
return "Pat.Donations[ donationid=" + donationid + " ]";
}
}
领域
@ManyToOne(optional = false)
private Sponsors sponsorid;
在捐赠
实体中,没有为级联配置。请尝试将其更改为:
@ManuToOne(optional = false, cascade = CascadeType.ALL)
private Sponsors sponsorid;
在试图获得文章和之间的关系时,我可能没有完全正确的映射,导致: 文章: 海德菲尔德: 实体已经更新,以反映使用的建议,这似乎可以修复特定的错误消息。我正在努力生成一个更有用的日志来跟踪发生的事情。
在同步过程中,我发现了一个错误
我有两个2类的关系多对多。 我想用这种方式创建一个新的recipie: 如果数据库中不存在成分,则会出现如下错误 有没有办法自动添加表中创建的对象? 我尝试添加CascateType. PERSIST但它也不工作
我最近遇到了一个问题。 我需要在页面上找到一个包含特定文本的div标签。问题是,文本被内部链接标记分成两部分,因此超文本标记语言树看起来像: 为了唯一地标识div标记,我需要div文本的两部分。当然,我会想出类似XPath的方法: 但是,它不起作用,第二部分找不到。 什么是唯一描述这种标签的最佳方法?
在游标和循环的帮助下,我将记录插入表中。关闭游标后,我编写了update语句来更新游标插入的一些记录,这样reords就不会更新。但我在外面进行了查询,然后更新了记录 我的尝试是删除程序,如果存在kpsf_inopdormantac; 请帮帮我
我已在centos 7上配置了kubernetes主机,并在另一个节点centos 7上配置了kubernetes节点 在kube Master上运行的服务: Kube-Controller-Manager kube-apiserver Kube-Scheduler ETCD 弗兰菲尔德 在kube节点上运行的服务: null 我不知道这个错误意味着什么,以及如何解决这个问题。请建议。