Could you please any one explain what is the meaning of below declaration
@Column(nullable = false )
@XmlElement(required = true, nillable = true )
which means difference between nullable and nillable ?
Could you please any one explain what is the meaning of below declaration
@Column(nullable = false )
@XmlElement(required = true, nillable = true )
which means difference between nullable and nillable ?
The @Column
annotation comes from JPA (the Java Persistence API) and specifies how a field is mapped to a database column. Using the nullable
attribute of the annotation, you specify whether NULL
values should be allowed in the database for this field.
The @XmlElement
annotation comes from JAXB (the Java API for XML Binding) and specifies how the field should be treated when converting this object to and from XML. If you set the nillable
attribute to true
, it means that in the XML it's allowed for the corresponding element to have an xsi:nil="true"
attribute.
Note that in XML there are subtle differences between an XML element being not present, being present but with an empty value and having an xsi:nil
attribute.
Whether it's appropriate to use an @XmlElement
annotation with nillable = true
attribute depends on the requirements for your application.