GeeCON Prague 2014*
The moose likes Object Relational Mapping and the fly likes How to create query with jpa, getting exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "How to create query with jpa, getting exception" Watch "How to create query with jpa, getting exception" New topic
Author

How to create query with jpa, getting exception

Pramod Kumar
Ranch Hand

Joined: Oct 05, 2007
Posts: 40
Hi,

I am using the following query to access the db values in to the list

Query qury = em.createQuery("SELECT usr FROM User");
List<User> results = (List <User> qury.getResultList();

User is a bean mapped to user table.

I am getting the follwing exception

java.lang.IllegalStateException: No data type for node: org.hibernate.hql.ast.tree.IdentNode
\-[IDENT] IdentNode: 'usr ' {originalText=usr}

Thanks,
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10146
    
165

Query qury = em.createQuery("SELECT usr FROM User");


Change it to



The alias usr wasn't defined


[My Blog] [JavaRanch Journal]
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10146
    
165

"ngpramod ngpramod"

Please check your private message, for a message from JavaRanch.
 
GeeCON Prague 2014
 
subject: How to create query with jpa, getting exception