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:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Object Relational Mapping
Convert from SQL to HQL grails
krs shah
Greenhorn
Posts: 3
posted 9 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I have this SQL which works fine
select a.* from classification c join (select id from taxonomy_node start with id = 5067 connect by nocycle prior id = parent_id) h on (c.node_id = h.id) join artifact a on (a.id = c.artifact_id) Where a.DOCUMENT_ID = 10462 AND c.active=1
I am trying to convert it to HQL and tried this
artifacts = Artifact.executeQuery("SELECT a FROM classification AS c " + "JOIN ( SELECT id FROM taxonomy_node START WITH id = :nodeId " + "CONNECT BY NOCYCLE PRIOR id = parent.id) AS h " + "ON c.node.id = h.id " + "JOIN artifact AS a ON a.id = c.artifactId " + "WHERE a.document_id = :docid AND c.active=1", [nodeId:filterByAssociatedNodeId ,docid: document.id], [max:limit, offset:startIndex])
But I am getting an error
org.springframework.orm.hibernate4.HibernateQueryException: unexpected token: ( near line 1, column 40 [SELECT a FROM classification AS c JOIN ( SELECT id FROM taxonomy_node START WITH id = :nodeId CONNECT BY NOCYCLE PRIOR id = parent.id) AS h ON c.node.id = h.id JOIN artifact AS a ON a.id = c.artifactId WHERE a.document_id = :docid AND c.active=1]; nested exception is org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: ( near line 1, column 40 [SELECT a FROM classification AS c JOIN ( SELECT id FROM taxonomy_node START WITH id = :nodeId CONNECT BY NOCYCLE PRIOR id = parent.id) AS h ON c.node.id = h.id JOIN artifact AS a ON a.id = c.artifactId WHERE a.document_id = :docid AND c.active=1]
Don't get me started about those stupid
light bulbs
.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Help with HQL Insert and Joins using Hibernate 3 / JPA
Serial number in SQL
example of where exists
HQL query with OneToMany
Inner Joins using HQL
More...