This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes JPA-Unknown entity type error when i actually have the entity in my DB Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "JPA-Unknown entity type error when i actually have the entity in my DB" Watch "JPA-Unknown entity type error when i actually have the entity in my DB" New topic
Author

JPA-Unknown entity type error when i actually have the entity in my DB

ambika mullasseri
Greenhorn

Joined: Jun 01, 2009
Posts: 28
i have a table employee_details

i tried to fire the query

Query query = em.createQuery(queryString);

where queryString = select emp.Emp_Id from employee_details emp


exception in thread "main" java.lang.IllegalArgumentException: An exception occurred while creating a query in EntityManager
at org.eclipse.persistence.internal.jpa.EntityManagerImpl.createQuery(EntityManagerImpl.java:1067)
at com.myoffice.hr.dao.Utils.Connection_Util.doSelection(Connection_Util.java:30)
at com.myoffice.hr.dao.Access_Employee_Detail.getEmployeeByName(Access_Employee_Detail.java:36)
at com.myoffice.hr.dao.Access_Employee_Detail.main(Access_Employee_Detail.java:44)
Caused by: Exception [EclipseLink-8034] (Eclipse Persistence Services - 1.1.2.v20090612-r4475): org.eclipse.persistence.exceptions.JPQLException
Exception Description: Error compiling the query [select emp.Emp_Id from employee_details emp]. Unknown entity type [employee_details].


but when i try to insert using em.persist(obj);
the data is getting inserted,which means the connection is correct.

please help me regarding this.


SCJP 6.0 86%
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3775

Is your domain object (POJO) you are trying to query against named "employee_details" ?


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
ambika mullasseri
Greenhorn

Joined: Jun 01, 2009
Posts: 28
no it is

@Entity
@Table(name="employee_details")
public class Employee_detail
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3775

Then you should use "Employee_detail" in your query.
ambika mullasseri
Greenhorn

Joined: Jun 01, 2009
Posts: 28
Thanks a lot .i am just trying out JPA for the first time.You really helped me out.
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3775

no problem
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JPA-Unknown entity type error when i actually have the entity in my DB
 
Similar Threads
About Named Queries
Querying in JPA
Recursive fetch join not recursively fetching all children
can any one help me?
JSP and MySql question