Reputation:
Table name in Databse is: empCode
Spring boot table mapping :
@Column(name="empCode")
String empCode;
getting error this:
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Invalid column name 'emp_code'.
RestController:
@GetMapping("/employee")
public List<Employee> findAll() {
return employeeService.findAll();
}
I didn't define this emp_code anywhere, please assist why?
I changed the name in table from empCode to empCODE then it is working but in my office project I am facing same error but there I can't change column name because other organisation also using same database.
Upvotes: 0
Views: 1380
Reputation: 178
Surround your column name with backticks:
@Column(name = "`empCode`")
This way hibernate will use the specific name instead of renaming it according to its own convention
Upvotes: 1