title: Use of @OneToMany or @ManyToMany targeting an unmapped class: kg.aladin.jdbc.Student.books[kg.aladin.jdbc.Book]
body: <p>I am having problems with one to many relationship I was surfing from web and could not fix. I double check @Entity declarations they were referring to <code>import javax.persistence.Entity;</code> before that I tried unidirectional only ManyToOne and it was working</p>
  
  <pre><code>@Entity
  @Table(name = "student")
  public class Student {
  @Id
  @GeneratedValue(strategy = GenerationType.IDENTITY)
  @Column(name = "id")
  private int id;
  
  @Column(name = "first_name")
  private String firstName;
  
  @Column(name = "last_name")
  private String lastName;
  
  @OneToMany(targetEntity = Book.class, mappedBy = "student", cascade = CascadeType.ALL)
  private Set&lt;Book&gt; books = new HashSet&lt;&gt;();
  
  public Student() {
  
  }
   // accessors ...
  }
  </code></pre>
  
  <p>and Book object</p>
  
  <pre><code>@Entity
  @Table(name = "book")
  public class Book {
  
  @Id
  @GeneratedValue(strategy = GenerationType.IDENTITY)
  @Column(name = "id")
  private Integer id;
  
  private String name;
  
  @ManyToOne
  @JoinColumn(name = "student_id")
  private Student student;
  
  public Book() {
  }
    //// accessors
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/J1s82.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/J1s82.png" alt="enter image description here"></a></p>
  
  <p>and here is my hibernate.cfg.xml</p>
  
  <pre><code>&lt;!DOCTYPE hibernate-configuration PUBLIC
      "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
      "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"&gt;
  </code></pre>
  
  <p></p>
  
  <pre><code>&lt;session-factory&gt;
  
      &lt;property name="connection.driver_class"&gt;com.mysql.jdbc.Driver&lt;/property&gt;
      &lt;property name="connection.url"&gt;jdbc:mysql://localhost:3306/***?useSSL=false&lt;/property&gt;
      &lt;property name="connection.username"&gt;***&lt;/property&gt;
      &lt;property name="connection.password"&gt;***&lt;/property&gt;
  
  
      &lt;property name="connection.pool_size"&gt;2&lt;/property&gt;
  
  
      &lt;property name="dialect"&gt;org.hibernate.dialect.MySQLDialect&lt;/property&gt;
  
  
      &lt;property name="show_sql"&gt;true&lt;/property&gt;
      &lt;property name="hibernate.hbm2ddl.auto"&gt;update&lt;/property&gt;
  
      &lt;property name="current_session_context_class"&gt;thread&lt;/property&gt;
  
  &lt;/session-factory&gt;
  </code></pre>
  
  <p></p>