I am getting this error:
Caused by: javax.ejb.EJBException: java.lang.IllegalArgumentException: org.hibernate.hql.internal.ast.QuerySyntaxException: TblEmployee is not mapped [FROM TblEmployee]
Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: TblEmployee` is not mapped
I researched the internet and it says I am not using the class name but the table name. I made sure I am doing this correctly. I am trying to connect to a sql server db.
JPA:
package com.ray.adtf.jpa;
import java.io.Serializable;
import javax.persistence.*;
import java.sql.Timestamp;
/**
* The persistent class for the tblEmployee database table.
*/
@Entity
@Table(name="tblEmployee")
@NamedQuery(name="TblEmployee.findAll", query="SELECT t FROM TblEmployee t")
public class TblEmployee implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Column(name="EmployeeID")
private int employeeID;
ejbpackage
com.ray.adtf.ejb;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import com.ray.adtf.jpa.TblEmployee;
import java.util.List;
@Stateless
public class GridMasterBean {
@PersistenceContext
private EntityManager em;
public List<TblEmployee> getDisplayGridList() {
return em.createQuery("select t FROM TblEmployee t", TblEmployee.class).getResultList();
}
persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
<persistence-unit name="Test-Persistence" transaction-type="RESOURCE_LOCAL">
<jta-data-source>java:/ProgramHierarchy</jta-data-source>
<class>com.ray.adtf.jpa.TblEmployee</class>
<class>com.ray.adtf.jpa.TblProgram</class>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
</persistence-unit>
</persistence>
What am I doing wrong?