Reputation: 2815
I am getting a 'Cannot insert the value NULL into column...' error when trying to save my Person object. It's being set properly as far as I can tell (after printing out the value), but it's failing on the save command.
The field that it cannot insert a null for is an inherited field from another class.
Here is my model:
public class BaseDomain
{
...
@Column(name="LST_UPD_PRG") private String lastUpdateProgram;
}
@Entity
@Table(name="PRSN_INF")
public class Person extends BaseDomain
{
...
@Column(name="FRS_NM") private String firstName;
@Column(name="LST_NM") private String lastName;
}
And then I'm attempting to save the person like so"
public static void main(String[] args)
{
...
Person person = new Person();
person.setFirstName("John");
person.setLastName("Doe");
person.setLastUpdateProgram("BatchJob_01");
personRepository.save(person);
}
And then, the save operation throws the error:
com.microsoft.sqlserver.jdbc.SQLServerException: Cannot insert the value NULL into column 'LST_UPD_PRG'...
I initially created the BaseDomain class because each of the tables in the database will have the LST_UPD_PRG column. Is there something wrong with the way I'm doing inheritence?
Upvotes: 0
Views: 1199
Reputation: 2079
I think you're missing the @MappedSuperclass annotation on the BaseDomain class. Adding that annotation will hopefully resolve your issue.
@MappedSuperclass
public class BaseDomain {
...
Upvotes: 2