I am working on a springboot application.
I am trying to save a list of custom objects in one of the column, but I am getting ERROR: relation doesn't exist exception on one column
EMPLOYEE DTO:
public class Employee {
private Integer employeeId;
private String employeeName;
private List<Address> addresses;
public Integer getEmployeeId() {
return employeeId;
}
public void setEmployeeId(Integer employeeId) {
this.employeeId = employeeId;
}
public String getEmployeeName() {
return employeeName;
}
public void setEmployeeName(String employeeName) {
this.employeeName = employeeName;
}
public List<Address> getAddresses() {
return addresses;
}
public void setAddresses(List<Address> addresses) {
this.addresses = addresses;
}
}
ADDRESS DTO:
public class Address {
private String state;
private String country;
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public Address(String state, String country) {
super();
this.state = state;
this.country = country;
}
public Address() {
}
}
Employee Service:
@Service
public class EmployeeService {
@Autowired
private UserRepository userRepository;
public void persist() {
Employee employee = new Employee();
employee.setEmployeeId(1001);
employee.setEmployeeName("John Doe");
employee.setAddresses(Arrays.asList(new Address("state_name", "country_name")));
userRepository.save(employee);
}
}
Data type of address is text in Postgres.
While executing my code, I am getting the below Exception:
org.postgresql.util.PSQLException: ERROR: relation “employee_address” does not exist.