【发布时间】:2020-08-10 07:21:07
【问题描述】:
我收到如下错误:
org.hibernate.hql.internal.ast.QuerySyntaxException: Employee is not mapped [from Employee]; nested exception is java.lang.IllegalArgumentException: org.hibernate.hql.internal.ast.QuerySyntaxException: Employee is not mapped [from Employee]",
"trace": "org.springframework.dao.InvalidDataAccessApiUsageException: org.hibernate.hql.internal.ast.QuerySyntaxException: Employee is not mapped [from Employee];
我已经创建了如下所示的模态
@Entity
@Table(name="employee_list")
public class Employee {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Column
private Integer id;
@Column
private String name;
@Column
private String gender;
@Column
private String department;
@Column
private Date dob;
// getters/setters
}
我的道实现:
@Repository
public class EmployeeDAOImpl implements EmployeeDAO {
@Autowired
private EntityManager entityManager;
@Override
public List<Employee> get() {
Session currentSession = entityManager.unwrap(Session.class);
Query<Employee> query = currentSession.createQuery("from Employee", Employee.class);
List<Employee> list = query.getResultList();
return list;
}
}
我错过了一些东西。
我无法确定到底是什么。
【问题讨论】:
标签: java spring hibernate spring-boot hql