0

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.

1

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

2 Comments

Not working still facing the same error.
And when you use @Column(name = "\"empCode\"") ?