I have an entity class which has an int field , in the table the cloumn type is Number (10,0). In the table default value is "NULL". Using Spring data JPA when I try select query using jpa I am getting below errors.
java.lang.IllegalArgumentException: Can not set int field com.test.app.entity.TestProject.baseUserIdNumber to null value
I cannot change anything in the table as this is already created and used in the production. Anything I can do with Entity class or JPQL
@Entity
public class TestProject {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int projectId;
private String description;
private String name;
private int seqNumber
private LocalDate startDateTime;
private LocalDate endDateTime;
@Column(name = "baseUserIdNumber")
private int myfield;
private String projStatus;
constructors ()
getters()
Setters()
}
You can just define the field with a default value and define as int instead of Integer so that it doesn't accept NULL values.
@Column(name = "my_column")
private int myField = 0;