Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Object Relational Mapping
Search Coderanch
Advance search
Google search
Register / Login
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
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Tim Cooke
Campbell Ritchie
Ron McLeod
Junilu Lacar
Liutauras Vilda
Sheriffs:
Paul Clapham
Jeanne Boyarsky
Henry Wong
Saloon Keepers:
Tim Moores
Tim Holloway
Stephan van Hulst
Piet Souris
Carey Brown
Bartenders:
Jesse Duncan
Frits Walraven
Mikalai Zaikin
Forum:
Object Relational Mapping
JPA - need help with query
Robert Tomson
Greenhorn
Posts: 9
posted 11 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
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
Posts: 82
posted 11 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
please show us your entity code and its mappings / annotations
Robert Tomson
Greenhorn
Posts: 9
posted 11 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
it was automatically generated by netBeans
@Entity @Table(name = "treemenu") public class TreeMenu implements Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Basic(optional = false) @Column(name = "itemIndex") private Integer itemIndex; @Basic(optional = false) @Column(name = "title") private String title; @OneToMany(mappedBy = "treeMenu") private Collection<TreeMenu> treeMenuCollection; @JoinColumn(name = "parentIndex", referencedColumnName = "itemIndex") @ManyToOne private TreeMenu treeMenu;
Joe carco
Ranch Hand
Posts: 82
posted 11 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Are you using JPA Query Language or Native Query Language?
Joe carco
Ranch Hand
Posts: 82
posted 11 years ago
1
Number of slices to send:
Optional 'thank-you' note:
Send
If you're using JPQL, try this
select t from TreeMenu t where t.treeMenu IS NULL
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
posted 11 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
thank you very much , its working, haha now when i know the answer its seams logical :P
Think of how dumb the average person is. Mathematically, half of them are EVEN DUMBER. Smart tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
JPA: Joins with unmapped tables
"JOIN" not working in JPA - Named Query
Help with JPA query please...
Hibernate query question
JPA Query using " where in" and setParameter
More...