When I am using @OneToMany/@ManyToOne Hibernate assumes the column name is ‘task_id’.
Is there an Annotiation to tell Hibernate that the Column name is e.g. ‘xxx’?
Table schema:
Project Task
------- ----
id id
text text
project
Code:
class Project {
...
@OneToMany(mappedBy = "task")
private List<Task> tasks;
}
class Task {
...
@ManyToOne
private Project project;
}
Thanks
Yes, it’s called …
@JoinColumn. Used as such:You would use it on the owning side of the relationship (
Task).