Please help. I'm new to hibernate 5 + MySQL so this might be silly scenario.
I'm trying to create a very basic social media app that allows to register, login, add friends. I'm getting this error:
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)
The error is thrown when i try to create a table to handle add friends feature.
I went ahead and created the table to associate users with their friends, it looks as follows:
Table name: users_users
Columns:
users_id - int(11)
friends_id - int(11)
Here's my model class:
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<User> friends;
    public Set<User> getFriends() {
        return friends;
    }
    public void setFriends(Set<User> 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;
    }
}
Here it is my code I'm using.
https://github.com/JAlonsoHdz/SocialNetworkWebApp
What am I doing wrong? Looks like hibernate is not mapping the users_users and the columns.
