我试图解决这个问题而没有成功:
org.springframework.dao.DataIntegrityViolationException: not-null property references a null or transient value :
ma.px.management.repository.service.bo.HtitrePortf.compteTitreCode; nested exception is org.hibernate.PropertyValueException:
not-null property references a null or transient value : ma.px.management.repository.service.bo.HtitrePortf.compteTitreCod at ma.px.management.repository.service.dao.TitrePortfTest.testDelete(TitrePortfTest.java:47)
Caused by: org.hibernate.PropertyValueException: not-null property references a null or transient value : ma.px.management.repository.service.bo.HtitrePortf.compteTitreCode
at ma.px.management.repository.service.dao.TitrePortfTest.testDelete(TitrePortfTest.java:47)
这是HtitrePortf
class:
package ma.px.management.repository.service.bo;
import java.io.Serializable
;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
/**
*
* @author imTech
*/
@Entity
@Table(name = "rtitre")
@XmlRootElement
@NamedQueries({
@NamedQuery(name = "Rtitre.findAll", query = "SELECT r FROM Rtitre r")
, @NamedQuery(name = "Rtitre.findByCode", query = "SELECT r FROM Rtitre r WHERE r.code = :code")
, @NamedQuery(name = "Rtitre.findByCodeISIN", query = "SELECT r FROM Rtitre r WHERE r.codeISIN = :codeISIN")
, @NamedQuery(name = "Rtitre.findByNom", query = "SELECT r FROM Rtitre r WHERE r.nom = :nom")
, @NamedQuery(name = "Rtitre.findByClasse", query = "SELECT r FROM Rtitre r WHERE r.classe = :classe")
, @NamedQuery(name = "Rtitre.findByCategorie", query = "SELECT r FROM Rtitre r WHERE r.categorie = :categorie")})
public class Rtitre implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Basic(optional = false)
@NotNull
@Size(min = 1, max = 10)
@Column(name = "code")
private String code;
@Basic(optional = false)
@NotNull
@Size(min = 1, max = 10)
@Column(name = "codeISIN")
private String codeISIN;
@Size(max = 15)
@Column(name = "nom")
private String nom;
@Size(max = 15)
@Column(name = "classe")
private String classe;
@Size(max = 15)
@Column(name = "categorie")
private String categorie;
public Rtitre() {
}
public Rtitre(String code) {
this.code = code;
}
public Rtitre(String code, String codeISIN) {
this.code = code;
this.codeISIN = codeISIN;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getCodeISIN() {
return codeISIN;
}
public void setCodeISIN(String codeISIN) {
this.codeISIN = codeISIN;
}
public String getNom() {
return nom;
}
public void setNom(String nom) {
this.nom = nom;
}
public String getClasse() {
return classe;
}
public void setClasse(String classe) {
this.classe = classe;
}
public String getCategorie() {
return categorie;
}
public void setCategorie(String categorie) {
this.categorie = categorie;
}
@Override
public int hashCode() {
int hash = 0;
hash += (code != null ? code.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 Rtitre)) {
return false;
}
Rtitre other = (Rtitre) object;
if ((this.code == null && other.code != null) || (this.code != null && !this.code.equals(other.code))) {
return false;
}
return true;
}
@Override
public String toString() {
return "ma.px.management.repository.service.bo.Rtitre[ code=" + code + " ]";
}
}