我尝试使用OneTomany
批注将LBG
连接到ILBG
package bg.moi.domain.model;
import javax.persistence.*;
import java.util.Date;
import java.util.Set;
@Entity
@Table(name = "l_bg" , catalog = "bds1")//, schema = "admbds",
@IdClass(LBgEntityPK.class)
public class LBgEntity {
@Id
@Column(name = "sid_o", nullable = false, precision = 0)
private int sidO;
public int getSidO() {
return sidO;
}
public void setSidO(int sidO) {
this.sidO = sidO;
}
@Id
@Column(name = "pnr_o", nullable = false)
private short pnrO;
public short getPnrO() {
return pnrO;
}
public void setPnrO(short pnrO) {
this.pnrO = pnrO;
}
@Basic
@Column(name = "egn", nullable = false, length = 10)
private String egn;
public String getEgn() {
return egn;
}
public void setEgn(String egn) {
this.egn = egn;
}
@Basic
@Column(name = "ime", nullable = false, length = 25)
private String ime;
public String getIme() {
return ime;
}
public void setIme(String ime) {
this.ime = ime;
}
@Basic
@Column(name = "prezime", nullable = false, length = 25)
private String prezime;
public String getPrezime() {
return prezime;
}
public void setPrezime(String prezime) {
this.prezime = prezime;
}
@Basic
@Column(name = "familno", nullable = false, length = 43)
private String familno;
public String getFamilno() {
return familno;
}
public void setFamilno(String familno) {
this.familno = familno;
}
@Basic
@Column(name = "dat_vav", nullable = false)
private Date datVav;
public Date getDatVav() { return datVav; }
public void setDatVav(Date datVav) { this.datVav = datVav; }
@Basic
@Column(name = "mrk_akt", nullable = false, length = 1)
private String mrkAkt;
public String getMrkAkt() {
return mrkAkt;
}
public void setMrkAkt(String mrkAkt) {
this.mrkAkt = mrkAkt;
}
@OneToMany(targetEntity = ILbgEntity.class,fetch = FetchType.LAZY)
@JoinColumns({@JoinColumn(name = "sidO",referencedColumnName = "sidO",insertable = false,updatable = false),
@JoinColumn(name = "pnrO" ,referencedColumnName = "pnrO",insertable = false,updatable = false)})
//@JoinColumn(foreignKey = @ForeignKey(name = "r130_1013"))
private Set<ILbgEntity> iLbgEntity;
public void setiLbgEntity(Set<ILbgEntity> iLbgEntity) { this.iLbgEntity = iLbgEntity; }
public Set<ILbgEntity> getiLbgEntity(){ return iLbgEntity; }
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
LBgEntity lBgEntity = (LBgEntity) o;
if (sidO != lBgEntity.sidO) return false;
if (pnrO != lBgEntity.pnrO) return false;
if (egn != null ? !egn.equals(lBgEntity.egn) : lBgEntity.egn != null) return false;
if (ime != null ? !ime.equals(lBgEntity.ime) : lBgEntity.ime != null) return false;
if (prezime != null ? !prezime.equals(lBgEntity.prezime) : lBgEntity.prezime != null) return false;
if (familno != null ? !familno.equals(lBgEntity.familno) : lBgEntity.familno != null) return false;
if (datVav != null ? !datVav.equals(lBgEntity.datVav) : lBgEntity.datVav != null) return false;
if (mrkAkt != null ? !mrkAkt.equals(lBgEntity.mrkAkt) : lBgEntity.mrkAkt != null) return false;
return true;
}
@Override
public int hashCode() {
int result = sidO;
result = 31 * result + (int) pnrO;
result = 31 * result + (egn != null ? egn.hashCode() : 0);
result = 31 * result + (ime != null ? ime.hashCode() : 0);
result = 31 * result + (prezime != null ? prezime.hashCode() : 0);
result = 31 * result + (familno != null ? familno.hashCode() : 0);
result = 31 * result + (datVav != null ? datVav.hashCode() : 0);
result = 31 * result + (mrkAkt != null ? mrkAkt.hashCode() : 0);
return result;
}
}
package bg.moi.domain.models;
import javax.persistence.Column;
import javax.persistence.Id;
import java.io.Serializable;
public class LBgEntityPK implements Serializable {
private int sidO;
private short pnrO;
@Column(name = "sid_o", nullable = false, precision = 0)
@Id
public int getSidO() {
return sidO;
}
public void setSidO(int sidO) {
this.sidO = sidO;
}
@Column(name = "pnr_o", nullable = false)
@Id
public short getPnrO() {
return pnrO;
}
public void setPnrO(short pnrO) {
this.pnrO = pnrO;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
LBgEntityPK that = (LBgEntityPK) o;
if (sidO != that.sidO) return false;
if (pnrO != that.pnrO) return false;
return true;
}
@Override
public int hashCode() {
int result = sidO;
result = 31 * result + (int) pnrO;
return result;
}
}
package bg.moi.domain.model;
import javax.persistence.*;
@Entity
@Table(name = "i_lbg", catalog = "bds1") //schema = "admbds",
@IdClass(ILbgEntityPK.class)
public class ILbgEntity {
@Id
@Column(name = "sid_o", nullable = false, precision = 0)
private int sidO;
public int getSidO() {
return sidO;
}
public void setSidO(int sidO) {
this.sidO = sidO;
}
@Id
@Column(name = "pnr_o", nullable = false)
private short pnrO;
public short getPnrO() {
return pnrO;
}
public void setPnrO(short pnrO) {
this.pnrO = pnrO;
}
@Basic
@Column(name = "ob1", nullable = false)
private int ob1;
public int getOb1() {
return ob1;
}
public void setOb1(int ob1) {
this.ob1 = ob1;
}
@Basic
@Column(name = "ob2", nullable = false)
private int ob2;
public int getOb2() {
return ob2;
}
public void setOb2(int ob2) {
this.ob2 = ob2;
}
@Basic
@Column(name = "ob3", nullable = false)
private int ob3;
public int getOb3() {
return ob3;
}
public void setOb3(int ob3) {
this.ob3 = ob3;
}
@Basic
@Column(name = "dtr", nullable = false)
private int dtr;
public int getDtr() {
return dtr;
}
public void setDtr(int dtr) {
this.dtr = dtr;
}
@Basic
@Column(name = "kpb", nullable = false)
private short kpb;
public short getKpb() {
return kpb;
}
public void setKpb(short kpb) {
this.kpb = kpb;
}
@Id
@Column(name = "pornom", nullable = false)
private short pornom;
public short getPornom() {
return pornom;
}
public void setPornom(short pornom) {
this.pornom = pornom;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ILbgEntity that = (ILbgEntity) o;
if (sidO != that.sidO) return false;
if (pnrO != that.pnrO) return false;
if (ob1 != that.ob1) return false;
if (ob2 != that.ob2) return false;
if (ob3 != that.ob3) return false;
if (dtr != that.dtr) return false;
if (kpb != that.kpb) return false;
if (pornom != that.pornom) return false;
return true;
}
@Override
public int hashCode() {
int result = sidO;
result = 31 * result + (int) pnrO;
result = 31 * result + ob1;
result = 31 * result + ob2;
result = 31 * result + ob3;
result = 31 * result + dtr;
result = 31 * result + (int) kpb;
result = 31 * result + (int) pornom;
return result;
}
}
package bg.moi.domain.models;
import javax.persistence.Column;
import javax.persistence.Id;
import java.io.Serializable;
public class ILbgEntityPK implements Serializable {
private int sidO;
private short pnrO;
private short pornom;
@Column(name = "sid_o", nullable = false, precision = 0)
@Id
public int getSidO() {
return sidO;
}
public void setSidO(int sidO) {
this.sidO = sidO;
}
@Column(name = "pnr_o", nullable = false)
@Id
public short getPnrO() {
return pnrO;
}
public void setPnrO(short pnrO) {
this.pnrO = pnrO;
}
@Column(name = "pornom", nullable = false)
@Id
public short getPornom() { return pornom; }
public void setPornom(short pornom) { this.pornom = pornom; }
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ILbgEntityPK that = (ILbgEntityPK) o;
if (sidO != that.sidO) return false;
if (pnrO != that.pnrO) return false;
if (pornom != that.pornom) return false;
return true;
}
@Override
public int hashCode() {
int result = sidO;
result = 31 * result + (int) pnrO;
result = 31 * result + (int) pornom;
return result;
}
}
从数据库生成类。
例外情况是:
null
有人有类似的问题吗?有什么解决办法吗?这可能是虫子吗?!
在@OneTomany的情况下使用下面的代码
@OneToMany(targetEntity = ILbgEntity.class, orphanRemoval = true, cascade = { CascadeType.ALL, CascadeType.REMOVE })
@JoinColumn(name = "sid_o", nullable = false)
@LazyCollection(LazyCollectionOption.FALSE)
@Fetch(FetchMode.SUBSELECT)
1)只将@id
和@column
批注放在entity类上。不要将它们放在IlbGentiTypk
类中。
2)不要在id类中添加setter。创建一个接受id字段的构造函数。
3)定义@joincolumns
时,请尝试使用数据库列名,而不是实体字段名:
@OneToMany(targetEntity = ILbgEntity.class,fetch = FetchType.LAZY)
@JoinColumns({@JoinColumn(name = "sid_o",referencedColumnName = "sid_o",insertable = false,updatable = false),
@JoinColumn(name = "pnr_o" ,referencedColumnName = "pnr_o",insertable = false,updatable = false)})
表1:字段:ID1 表2:字段:ID2
首先,我的英语很差,如果我的写作让人困惑,请原谅。 我试图在实例之间创建以下关系:如果,和,那么。在我的例子中,我想指定如果一个“管理”一名员工,并且与有相同的工作,那么他也管理同一名员工。 我尝试使用链属性来实现这一点,但当我激活它时,推理器(事实1.6.5)不起作用(日志显示使用了一个非简单属性)。我认为问题在于属性“manages”是不对称的和不可伸缩的,而属性“sameJob”是可传递的和
我想比较同一个工作区文件夹中的两个路径,并获得它们之间的相对路径: 并从secondPath返回firstPath相对路径 谢谢你的帮助。
我使用以下代码运行模式注册服务器: 使用docker组件部署后,我得到以下错误: Kafka 在本地运行(它不在泊坞窗中运行),顺便说一句,kafka 服务器属性具有以下特性: broker.id=0 侦听器=PLAINTEXT://localhost:9092 监听器.security.protocol.map=纯文本:纯文本,SSL:SSL,SASL_PLAINTEXT:SASL_PLAINT
Flink社区! 我有一个关于在Flink中连接相同键上的多个流的问题(等连接)。我还是一个新手,正在为我的团队评估Flink,将我们的Spark批处理应用程序迁移到流处理。 注意:我看了FabianHüske的这篇关于加入处理的文章:窥视Apache Flink的引擎室。 为了简化问题,假设您有3个流,每个流都有唯一的记录,可以通过id字段进行键控。对于流中的每条记录,您将在其他流中找到相应的记
问题内容: 我如何(或可以使用哪些工具)在两个或多个元素之间画线以连接它们?HTML / CSS / JavaScript / SVG / Canvas的任何组合都可以。 如果您的答案支持以下任何一项,请提及: 可拖动元素 可拖动/可编辑的连接 避免元素重叠 该问题已更新,以巩固其众多变体。 问题答案: 是一个支持拖放的可用选项,从其众多演示包括Flowchart演示可以看出。 它提供免费的社区版