This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
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


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
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: 10239
    
168

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: 10239
    
168

"ngpramod ngpramod"

Please check your private message, for a message from JavaRanch.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to create query with jpa, getting exception