wood burning stoves 2.0*
The moose likes Object Relational Mapping and the fly likes JPA - need help with query 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 - need help with query" Watch "JPA - need help with query" New topic
Author

JPA - need help with query

Robert Tomson
Greenhorn

Joined: Nov 12, 2010
Posts: 9
hi, i am working on recreating tree from database table,



what i need to do is to select all items where parentIndex is null

so in mysql i can do : SELECT * FROM `treemenu` WHERE parentIndex IS NULL

how should query look like in jpa to get same results ?

"SELECT t FROM TreeMenu t WHERE t.parentIndex IS NULL" gives me 'unknown state or association field [parentIndex]'
Joe carco
Ranch Hand

Joined: Apr 14, 2009
Posts: 82
please show us your entity code and its mappings / annotations
Robert Tomson
Greenhorn

Joined: Nov 12, 2010
Posts: 9
it was automatically generated by netBeans

Joe carco
Ranch Hand

Joined: Apr 14, 2009
Posts: 82
Are you using JPA Query Language or Native Query Language?
Joe carco
Ranch Hand

Joined: Apr 14, 2009
Posts: 82
If you're using JPQL, try this



in your query youre using a database column. I assume you are using JPQL, there the atabase column "parentindex" correctly causes that exception
Robert Tomson
Greenhorn

Joined: Nov 12, 2010
Posts: 9
thank you very much , its working, haha now when i know the answer its seams logical :P
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JPA - need help with query
 
Similar Threads
Hibernate query question
Help with JPA query please...
"JOIN" not working in JPA - Named Query
JPA: Joins with unmapped tables
JPA Query using " where in" and setParameter