Very slick. My only suggestion is to allow a bit more terseness by adding static versions of all the calls that can happen at the beginning of the Query. The static versions would just create a new SQL object and pass the call on to the SQL object's call.<p>Instead of:<p><pre><code> new SQL().SELECT_ALL()
</code></pre>
You could have Query.SELECT_ALL()<p>Ideally Java would be cool with having Static and non-Static methods with identical signatures and names, but alas, looks like a static class Query or whatever would be the way to do this.
This looks very similar to jOOQ in my first impression. <a href="http://www.jooq.org/" rel="nofollow">http://www.jooq.org/</a><p>I wonder if the author was aware of the existence of jOOQ?
This is opinion only, so please don't take this as me being negative: I really like the idea, but there's one thing which need to happen for this to be upstream.<p>Most decent IDE's (Idea and few others) are clever enough to understand the SQL between quotation marks and if connected to database will give you instant errors if something is incorrect - misspelled names, missing commas, etc. Sometimes this can be a big time saver.
I wrote something like this for C# just yesterday as I couldn't find an sql builder with a real fluent interface. I found one which pretended to be fluent by returning itself after each method call, but that completely misses the point, because you want each call to create a mutation but leave the original in tact. That allows me to build a query using all of the WHEREs and then branch it off into two separate queries.. one for COUNT and one to select the actual data.<p>Just wondering.. did you create this to be used in the read layer of a DDD/CQS based system?<p>Edit: actually looking at the source it appears this one is similar to the one i saw in C# where each call just returns the same builder rather than a new version
I don't like this. I'm strongly of the opinion that SQL is a beautiful language, able to express in terse yet readable statements operations which would take many pages of Java to execute. Why try and wrap it up, and pretend that you are writing Java, when you're still writing SQL?<p>Please don't take this as a dig at you or your code - everyone has an itch to scratch, and I'm quite sure writing this was fun.
is anyone wants something similar for c, i am looking for beta users (users that are happy with a beta release, not users less impressive than alpha users...) of c-orm, which includes (a very minimal version of) this - <a href="https://bitbucket.org/isti/c-orm/wiki/SQL#markdown-header-conditional-statements" rel="nofollow">https://bitbucket.org/isti/c-orm/wiki/SQL#markdown-header-co...</a>
Looks cool! I wrote a similar library that's been working out well in my projects:<p><a href="https://github.com/jkrasnay/sqlbuilder" rel="nofollow">https://github.com/jkrasnay/sqlbuilder</a>
Hmm looks a bit like Squiggle SQL, <a href="http://code.google.com/p/squiggle-sql/" rel="nofollow">http://code.google.com/p/squiggle-sql/</a> but less