4

i have this code

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);

}

and this error

Internal Exception: java.sql.SQLException: ORA-01400: cannot insert NULL into ("RPINGRE"."ARE_SOLI"."ARE_SOLI_SOLIASPI_ID")

This is Aspirante Entity (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;

and Solicitud Entity (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;

.....
}
skaffman
  • 398,947
  • 96
  • 818
  • 769
JoseJC
  • 758
  • 1
  • 9
  • 20

2 Answers2

-1

try changing GenerationType.SEQUENCE to GenerationType.Auto.

lahiruhashan
  • 120
  • 1
  • 11
-2

The ORA-01400 error says that you are trying to insert a NULL into a column defined as NOT NULL. I suggest you ether set a default value on the column or have your code make sure the NOT NULL columns have data before you do the INSERT (or use an NVL function in your INSERT statement)

  • the user is asking how to solve the onetoone error. As for the error is obvious and your explanation expendable – eduyayo Oct 27 '15 at 12:22