ObjectDB ObjectDB

How to avoid NULL values on Embedded entities


Hi there. I'm new on this. trying to learn.

I'm trying to make a value non nulleable. So, when I try to upload to the DB this field as null, it give me an error.

I tried this, but it didn't work:

public class Pedido {
    @Id @GeneratedValue
    private long id;
    @Embedded private Direccion origen;
    @ManyToOne private Cliente cliente; //Opcional
    @Basic(optional=false) private Date fechaYhora; //Fecha en que se debe enviar el coche


public class Direccion {
    @Basic(optional=false) private String calle;
    @Basic(optional=false) private int numero;
    @Basic(optional=false) private String ciudad;
    @Basic(optional=false) private String provincia;
    @Basic(optional=false) private String pais;
    @Basic(optional=false) private int cp;



And how to make the emmbedeable Direccion not nulleable?

In the code above, the optional=false, works only on fechaYhora, but it doesn't work inside Direccion fields.

Sorry if my english is not perfecto, just ask if i'm not clear



Sorry. Solved. The code was working, the problem was that i'm savin an empty string "" (not null)



To post on this website please sign in.