• 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Does an ORM framework exist for JAVA that generates SQL so you only ever deal with Objects?

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey all,

I came across a Python Web framework called Django which has an interesting way of dealing with database access. You never actually write any SQL. Instead you query objects that map to database tables. The clever bit is that where in Hibernate you'd have to write some HQL to retrieve the data from the DB. Django writes the SQL for you in the background, executes it and returns it back as an object.

I've been using Hibernate and Ibatis for a couple of years now and I was wondering if theres a java framework that closely matches this behavoir?

If there aint then I might have a go at writing one!

http://www.djangoproject.com/
 
author and cow tipper
Posts: 5009
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Howdy Greenhorn! Welcome to the JavaRanch!

First things first. We need to mosey on over to our JavaRanch profiles and update our name to make sure we're not makin' a mockery of ye olde JavaRanch Naming Policy.

Now, onto your question. I think you'd be impressed if you looked at the Hibernate/JPA Criteria API. It does just that - objects are used, Java APIs do things like create restriction classes and example classes, and given an example, restriction, or other type of criteria, very complex SQL is created under the covers. It's pretty awesome, and no HQL/SQL is required.

Here's a little something I wrote on the topic of the Hibernate Criteria API:

Using the Criteria API to Perform Queries

Here's an example of the code:



And another one:



Now go deal with that darn name of yours, before the Sheriffs come a wanderin!

-Cameron McKenzie
 
Stephen Foster
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the quick reply! Hibernate/JPA API looks exactily what I'm looking for. I'll check it out thanks.

p.s. Who says my name isn't Beave Beave
 
Cameron Wallace McKenzie
author and cow tipper
Posts: 5009
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Quick replies is what we pride ourselves on here at the ranch!

And keep asking good questions, and we'll keeps trying to help out with good answers.

And thanks for being so darned understanding about the name policy.

-Cameron McKenzie
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are many ORMs that eliminate (some, most) of the need for hand-written SQL, but bear in mind they might not always be appropriate, or the best solution. Hibernate is amongst the most popular/best known, but there are others.
 
We find this kind of rampant individuality very disturbing. But not this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic