@Column(nullable=false) validating the null check at application level

Viewed 838

From my understanding nullable = false(let say for column customerid) is only useful for creating schemas using hibernate and it should not do any kind of validation before persisting. My database column has no such constraint(it can take null values), while persisting the entity with customerid null, getting this error

Caused by: org.hibernate.PropertyValueException: not-null property references a null or transient value :b
    at org.hibernate.engine.internal.Nullability.checkNullability(Nullability.java:111) ~[hibernate-core-5.4.27.Final.jar:5.4.27.Final]
    at org.hibernate.engine.internal.Nullability.checkNullability(Nullability.java:55) ~[hibernate-core-5.4.27.Final.jar:5.4.27.Final]
    at 

This error started keep coming after i update my spring boot version to 2.4.2

Entity class

public class FaceIndexResponse extends AuditEntity {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id;
    @Column(name="customer_id",nullable = false)
    private String customerId;
    @Column(name="application_id")
    private String appid;}

Service class where i was trying to save the above entity

public IndexFacesResult handle(FaceIndexModel model) throws IOException{
    FaceIndexResponse response=new FaceIndexResponse();
    response.setAppid(model.getApplicationId);
    faceIndexResponseJpa.save(response);
 }


                                   Table "public.face_index_response"
     Column     |            Type             | Collation | Nullable |             Default              
----------------+-----------------------------+-----------+----------+----------------------------------
 id             | integer                     |           | not null | generated by default as identity
 customer_id    | character varying(64)       |           |          | 
 application_id | character varying(64)       |           |          | 
1 Answers
Related