Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

class library representing SQL statement?

 
Donal Lynch
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I'm looking for a library that manipulates SQL statements, something along the lines of:

It's for an application where the same data is being looked at by users with various combinations of permissions and preferences, so there's a core query that stays the same, with rows and columns added or taken away for specific invocations.
The other thing I'd like to be able to do is something like:

It's simple, it must have been done before, but my Google queries (eg "java sql") are unsuccessful. Thanks for any help.
--
Donal
 
Michael Zalewski
Ranch Hand
Posts: 168
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out Torque Criteria
 
Donal Lynch
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello again,
Thanks Michael for the pointer to Torque, which I tried and liked. The best way of summarising its convenience is that Torque is to accessing databases as RMI is to accessing services over the network: it compiles database peer classes that represent information held in a database, saving the tedium of coding accessor methods and data conversions by hand, and hiding the conceptual mismatches of objects communicating with things that aren't objects.
However I have a doubt about whether Torque is appropriate for my application, which doesn't do much more than extracting tabular information from a database and displaying the same tabular information to the user. I don't know if it's worth converting each row in a table to an object of a specially compiled class when this object doesn't encapsulate any business functionality and doesn't participate in any interactions apart from getXxx and setXxx.
The small amount of intelligence in my application seems to be focussed on constructing queries and views of tabular data, so I'm looking for a class library that represents those concepts rather than hiding them. The Torque Criteria class looks like what I want, except I can't see any way of using it except by passing it to a Torque-generated database peer object, which I don't want.
 
Lukas Eder
Ranch Hand
Posts: 48
5
Java Oracle Postgres Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Back in 2002, there weren't many libraries that elegantly implemented SQL building in a typesafe way. Today, you have a broad choice. Just to name a few:

  • jOOQ: http://www.jooq.org
  • JaQu: http://www.h2database.com/html/jaqu.html
  • iciql: http://iciql.com/ (a friendly fork of JaQu)
  • Quaere: http://quaere.codehaus.org
  • Jequel: http://www.jequel.de (in maintenance mode, I think)
  • Squiggle: http://code.google.com/p/squiggle-sql (in maintenance mode, I think)


  • Apart from the above, there is always

  • Hibernate/JPA CriteriaQuery

  •  
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic