title: ManyToOne relation in Hibernate, not in Database
body: <p>I have an entity named 'Department' and another entity named 'student'. I know the department will have many students and there shoulld be relation between these two tables in database. But in my project, the DB tables are already there and there is no relation (foreign key) between department and student tables.</p>
  
  <p>In entity class, student.java , there is a relation written as,</p>
  
  <pre><code>@ManyToOne(fetch = FetchType.LAZY)
  @JoinColumn(name = 'DeptId', nullable = false, insertable = false, updatable = false)
  Department department
  </code></pre>
  
  <p>I am confused about this existing code.</p>
  
  <p>When I wrote a test, I am fetching the department from DB by deptId and set the student entity as,</p>
  
  <pre><code>student.setDepartment(department);
  </code></pre>
  
  <p>This doesn't populate the DB column 'DEPTID' in student table.</p>
  
  <p>Since there's no student collection in Department, I cannot set the student as, </p>
  
  <pre><code>department.addStudents(student);
  </code></pre>
  
  <p>I am not sure whether we can insist a @ManyToOne relation without a relation between the tables in DB.</p>
  
  <p>Please let me know how I can fix this issue so that the 'DEPTID' column in student table is populated with the correct data.</p>
  
  <p>Thanks in advance,
  BS</p>