I am writing a spring boot + Hibernate JPA application and i my hibernate code is not working in that below are the details
Entity Class:
@Entity
@Table(name="user")
public class UserBean {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "idUser")
String id;
@Column(name = "UserName")
String name;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
Service/DAO:
@Transactional
@Repository
public class SpringBootService {
@PersistenceContext
private EntityManager entityManager;
public boolean userLogin(UserBean bean) {
String hql = "FROM UserBean WHERE id = ? ";
int count = entityManager.createQuery(hql).setParameter(0, bean.getId())
.getResultList().size();
return count > 0 ? true : false;
}
}
and below is my table
I am getting the below exception
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'userbean0_.id_user' in 'field list'
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_162]
I have checked the table name and the column names in the entity class all of then are correct and this is a simple mapping i am not involving second table as well.
