I\'m trying to get a list of all the users from \"users\" table and I get the following error:
org.hibernate.hql.internal.ast.QuerySyntaxException: users is
Added @TABLE(name = "TABLE_NAME") annotation and fixed. Check your annotations and hibernate.cfg.xml file. This is the sample entity file that works:
import javax.persistence.*;
@Entity
@Table(name = "VENDOR")
public class Vendor {
//~ --- [INSTANCE FIELDS] ------------------------------------------------------------------------------------------
private int id;
private String name;
//~ --- [METHODS] --------------------------------------------------------------------------------------------------
@Override
public boolean equals(final Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
final Vendor vendor = (Vendor) o;
if (id != vendor.id) {
return false;
}
if (name != null ? !name.equals(vendor.name) : vendor.name != null) {
return false;
}
return true;
}
//~ ----------------------------------------------------------------------------------------------------------------
@Column(name = "ID")
@GeneratedValue(strategy = GenerationType.AUTO)
@Id
public int getId() {
return id;
}
@Basic
@Column(name = "NAME")
public String getName() {
return name;
}
public void setId(final int id) {
this.id = id;
}
public void setName(final String name) {
this.name = name;
}
@Override
public int hashCode() {
int result = id;
result = 31 * result + (name != null ? name.hashCode() : 0);
return result;
}
}