2011-07-20 4 views
2

j'ai ce codeORA-01400 ne peut pas insérer erreur nul dans relation un à un

public void guardarAspirante(AspiranteDTO aspiranteDTO) { 
    Aspirante aspirante = new Aspirante(); 
    String usuarioMovimiento = AspiranteCN.class.getSimpleName(); 
    Date fecha = new Date(); 
    aspirante.setCodigoAlumno(aspiranteDTO.getCodigoUniversitario()); 
    aspirante.setNombre(aspiranteDTO.getNombre()); 
    aspirante.setApellidoPaterno(aspiranteDTO.getPrimerApellido()); 
    aspirante.setApellidoMaterno(aspiranteDTO.getSegundoApellido()); 
    aspirante.setUsuarioMovimiento(usuarioMovimiento); 
    aspirante.setFechaMovimiento(fecha); 

    Solicitud solicitud = new Solicitud(aspirante.getSolicitudId()); 
    solicitud.setAspirante(aspirante); 
    solicitud.setSolicitudId(aspirante.getSolicitudId()); 
    solicitud.setOfertaId(aspiranteDTO.getOfertaAcademica()); 
    solicitud.setPeriodoId(aspiranteDTO.getPeriodo()); 
    solicitud.setAportacion(aspiranteDTO.getAportacionVoluntaria()); 
    solicitud.setFechaMovimiento(fecha); 
    solicitud.setUsuarioMovimiento(usuarioMovimiento); 
    aspirante.setSolicitud(solicitud); 

    .... 

    aspiranteDAO.persist(aspirante); 

}

et cette erreur

Exception interne: java.sql.SQLException: ORA -01400: impossible d'insérer NULL dans ("RPINGRE". "ARE_SOLI". "ARE_SOLI_SOLIASPI_ID")

s Aspirante entité (Fragment)

@Entity 
@Table(name = "ARE_SOLIASPI", catalog = "", schema = "RPINGRE") 
public class Aspirante implements Serializable { 
private static final long serialVersionUID = 1L; 
@SequenceGenerator(sequenceName = "RPINGRE.SQ_ARE_SOLIASPI", 
name = "RPINGRE.SQ_ARE_SOLIASPI", 
initialValue = 1, 
allocationSize = 1) 
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "RPINGRE.SQ_ARE_SOLIASPI") 
@Id 
@Basic(optional = false) 
@Column(name = "ARE_SOLIASPI_ID") 
private Long solicitudId; 
@Basic(optional = false) 
@Column(name = "ARE_SOLIASPI_CODIGO") 
private String codigoAlumno; 
@Basic(optional = false) 
@Column(name = "ARE_SOLIASPI_NOMBRE") 
private String nombre; 
@Column(name = "ARE_SOLIASPI_APE_PATERNO") 
private String apellidoPaterno; 
@Column(name = "ARE_SOLIASPI_APE_MATERNO") 
private String apellidoMaterno; 
@Basic(optional = false) 
@Column(name = "ARE_SOLIASPI_MOV_USUARIO") 
private String usuarioMovimiento; 
@Basic(optional = false) 
@Column(name = "ARE_SOLIASPI_MOV_FECHA") 
@Temporal(TemporalType.TIMESTAMP) 
private Date fechaMovimiento; 
@OneToOne(cascade = CascadeType.ALL, mappedBy = "aspirante", fetch = FetchType.LAZY) 
private Solicitud solicitud; 

et Solicitud Entité (Fragment)

@Entity 
@Table(name = "ARE_SOLI", catalog = "", schema = "RPINGRE") 
public class Solicitud implements Serializable { 

private static final long serialVersionUID = 1L; 
@Id 
@Basic(optional = false) 
@Column(name = "ARE_SOLI_SOLIASPI_ID") 
private Long solicitudId; 
@Basic(optional = false) 
@Column(name = "ARE_SOLI_MOV_USUARIO") 
private String usuarioMovimiento; 
@Basic(optional = false) 
@Column(name = "ARE_SOLI_MOV_FECHA") 
@Temporal(TemporalType.TIMESTAMP) 
private Date fechaMovimiento; 
@Column(name = "ARE_SOLI_PERIODO_ID") 
private String periodoId; 
@Column(name = "ARE_SOLI_OFERTA_ID") 
private Long ofertaId; 
@Column(name = "ARE_SOLI_APORTACION") 
private Long aportacion; 
@JoinColumn(name = "ARE_SOLI_SOLIASPI_ID", referencedColumnName = "ARE_SOLIASPI_ID", insertable = false, updatable = false, nullable = false) 
@OneToOne(optional = false, fetch = FetchType.LAZY) 
private Aspirante aspirante; 

..... 
} 

Répondre

-1

L'erreur ORA-01400 dit que vous essayez d'insérer une valeur NULL dans une colonne définie comme NOT NULL. Je vous suggère de définir une valeur par défaut sur la colonne ou d'avoir votre code assurez-vous que les colonnes NOT NULL ont des données avant de faire l'INSERT (ou utilisez une fonction NVL dans votre instruction INSERT)

+0

l'utilisateur demande comment résoudre l'erreur onetoone. En ce qui concerne l'erreur est évidente et votre explication consomptible – eduyayo

Questions connexes