Win a copy of Succeeding with AI this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Junilu Lacar
Sheriffs:
  • Tim Cooke
  • Jeanne Boyarsky
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • fred rosenberger
  • Frits Walraven

JPA - need help with query

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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]'
 
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please show us your entity code and its mappings / annotations
 
Robert Tomson
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it was automatically generated by netBeans

 
Joe carco
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you using JPA Query Language or Native Query Language?
 
Joe carco
Ranch Hand
Posts: 82
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you very much , its working, haha now when i know the answer its seams logical :P
 
Hey, sticks and stones baby. And maybe a wee mention of my stuff:
Two software engineers solve most of the world's problems in one K&R sized book
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic