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
Tim Cooke
paul wheaton
Liutauras Vilda
Ron McLeod
Sheriffs:
Jeanne Boyarsky
Devaka Cooray
Paul Clapham
Saloon Keepers:
Scott Selikoff
Tim Holloway
Piet Souris
Mikalai Zaikin
Frits Walraven
Bartenders:
Stephan van Hulst
Carey Brown
Forum:
Object Relational Mapping
Convert SQL to HQL
Chris Boldon
Ranch Hand
Posts: 190
posted 18 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
How would I convert this query to HQL?
select PMO.PROJECT.PROJECT_ORGANIZATION, count(PROJECT_ORGANIZATION) from PMO.PROJECT group by PROJECT_ORGANIZATION
This is my mapping:
<hibernate-mapping> <class name="com.x.pmo.vo.ProjectImpl" table="PROJECT" schema="PMO"> <id name="projectId" type="string"> <column name="project_id" length="15" /> <generator class="assigned" /> </id> <property name="projectName" type="string"> <column name="project_name" length="45" /> </property> <property name="projectOrganization" type="string"> <column name="project_organization" length="45" /> </property> </class> </hibernate-mapping>
Scott Johnson
Ranch Hand
Posts: 518
posted 18 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Except for the table and column names, the SQL and HQL will look identical in this case.
See
section 14.6
of the Hibernate manual.
[ November 02, 2006: Message edited by: Scott Johnson ]
William Eichele
Greenhorn
Posts: 4
posted 14 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
How about that?
SELECT statistic.* FROM statistic INNER JOIN (SELECT MAX(st_id) AS id FROM statistic WHERE status = 'N' GROUP BY bc_id) ids ON statistic.st_id = ids.id ORDER BY bussinessprocessID;
Greetings
Will
William Eichele
Greenhorn
Posts: 4
posted 14 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
does nobody have an answer? please i need it for the work :>
Paul Sturrock
Bartender
Posts: 10336
I like...
posted 14 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
What is the question? I though Chris already had his answer?
JavaRanch FAQ
HowToAskQuestionsOnJavaRanch
William Eichele
Greenhorn
Posts: 4
posted 14 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
my problem is that i have to convert this sql query
SELECT statistic.* FROM statistic INNER JOIN (SELECT MAX(st_id) AS id FROM statistic WHERE status = 'N' GROUP BY bc_id) ids ON statistic.st_id = ids.id ORDER BY bussinessprocessID;
into HQL. I don't need or want
, to learn HQL in generally. So i asked if, someone could please help my with that.
William Eichele
Greenhorn
Posts: 4
posted 14 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
hello?
Paul Sturrock
Bartender
Posts: 10336
I like...
posted 14 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
No one can convert your SQL to HQL without knowing what your mapped objects are called and how they are associated (hence, I'm guessing, the deafening silence).
This
should explain how it works.
JavaRanch FAQ
HowToAskQuestionsOnJavaRanch
I don't always make ads but when I do they're tiny
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Hibernate Newbie - 1 to Many Relation Tutorial
Hibernate Issue
hibernate update in single transcation
Update Single value in a row
Assigning values to a returned object from query
More...