title: org.hibernate.engine.jdbc.spi.SqlExceptionHelper - Unknown column in 'field list'
body: <p>Please help. I'm new to hibernate 5 + MySQL so this might be silly scenario.</p>
  
  <p>I'm trying to create a very basic social media app that allows to register, login, add friends. I'm getting this error:</p>
  
  <pre><code>23:47:57.340 [http-nio-8080-exec-6] ERROR     org.hibernate.engine.jdbc.spi.SqlExceptionHelper - Unknown column 'friends0_.User_Id' in 'field list'
      javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not extract ResultSet
          at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:149)
          at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:157)
          at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1423)
          at com.alonso.socialnetworks.dao.UserDAO.getUserByName(UserDAO.java:29)
          at com.alonso.socialnetworks.action.LoginAction.validate(LoginAction.java:34)
          at com.opensymphony.xwork2.validator.ValidationInterceptor.doBeforeInvocation(ValidationInterceptor.java:250)
          at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:262)
          at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:49)
          at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:99)
          at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
          at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.doIntercept(ConversionErrorInterceptor.java:142)
          at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:99)
          at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
          at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:137)
          at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:99)
          at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
          at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:137)
  </code></pre>
  
  <p>The error is thrown when i try to create a table to handle add friends feature.</p>
  
  <p>I went ahead and created the table to associate users with their friends, it looks as follows:</p>
  
  <p>Table name: users_users</p>
  
  <p>Columns:</p>
  
  <p>users_id -     int(11) </p>
  
  <p>friends_id -    int(11)</p>
  
  <p>Here's my model class:</p>
  
  <pre><code>package com.alonso.socialnetworks.model;
  
  import java.util.Set;
  
  import javax.persistence.Column;
  import javax.persistence.Entity;
  import javax.persistence.FetchType;
  import javax.persistence.GeneratedValue;
  import javax.persistence.Id;
  import javax.persistence.JoinColumn;
  import javax.persistence.JoinTable;
  import javax.persistence.OneToMany;
  import javax.persistence.Table;
  
  import org.hibernate.annotations.GenericGenerator;
  
  @Entity
  @Table(name = "Users")
  public class User {
  
      @Id
      @GenericGenerator(name = "inc", strategy = "increment")
      @GeneratedValue(generator = "inc")
      @Column(name = "Id")
      private Integer id;
  
      @Column(name = "name")
      private String userName;
  
      @Column(name = "password")
      private String password;
  
      @OneToMany(fetch=FetchType.EAGER)
      @JoinTable(name="users_users")
      @JoinColumn(name="users_id")
      private Set&lt;User&gt; friends;
  
      public Set&lt;User&gt; getFriends() {
          return friends;
      }
  
      public void setFriends(Set&lt;User&gt; friends) {
          this.friends = friends;
      }
  
      public Integer getId() {
          return id;
      }
  
      public void setId(Integer id) {
          this.id = id;
      }
  
      public String getUserName() {
          return userName;
      }
  
      public void setUserName(String userName) {
          this.userName = userName;
      }
  
      public String getPassword() {
          return password;
      }
  
      public void setPassword(String password) {
          this.password = password;
      }
  
  }
  </code></pre>
  
  <p>Here it is my code I'm using.</p>
  
  <p><a href="https://github.com/JAlonsoHdz/SocialNetworkWebApp" rel="nofollow noreferrer">https://github.com/JAlonsoHdz/SocialNetworkWebApp</a></p>
  
  <p>What am I doing wrong?
  Looks like hibernate is not mapping the users_users and the columns.</p>