TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Show HN: fluent SQL – a minimalistic SQL builder for Java

35 pointsby ivancerasalmost 12 years ago
A minimalistic Fluent SQL API for Java built with one compilation unit aimed to resemble the code to your original SQL code

11 comments

cpfohlalmost 12 years ago
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&#x27;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.
评论 #6025019 未加载
评论 #5957575 未加载
jhhalmost 12 years ago
This looks very similar to jOOQ in my first impression. <a href="http://www.jooq.org/" rel="nofollow">http:&#x2F;&#x2F;www.jooq.org&#x2F;</a><p>I wonder if the author was aware of the existence of jOOQ?
评论 #5957313 未加载
评论 #5959077 未加载
zeroDivisiblealmost 12 years ago
This is opinion only, so please don&#x27;t take this as me being negative: I really like the idea, but there&#x27;s one thing which need to happen for this to be upstream.<p>Most decent IDE&#x27;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.
grandpoobahalmost 12 years ago
I wrote something like this for C# just yesterday as I couldn&#x27;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&#x2F;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
评论 #6025024 未加载
ww520almost 12 years ago
Looks cool. I love DSL style API for chaining calls. Make it so simple.
steve_barhamalmost 12 years ago
I don&#x27;t like this. I&#x27;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&#x27;re still writing SQL?<p>Please don&#x27;t take this as a dig at you or your code - everyone has an itch to scratch, and I&#x27;m quite sure writing this was fun.
评论 #5957302 未加载
评论 #5957980 未加载
评论 #6025429 未加载
评论 #5957181 未加载
评论 #5957345 未加载
andrewcookealmost 12 years ago
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:&#x2F;&#x2F;bitbucket.org&#x2F;isti&#x2F;c-orm&#x2F;wiki&#x2F;SQL#markdown-header-co...</a>
mimogalmost 12 years ago
Nice, but anyone needing something like this should probably consider looking at jooq.
jkrasnayalmost 12 years ago
Looks cool! I wrote a similar library that&#x27;s been working out well in my projects:<p><a href="https://github.com/jkrasnay/sqlbuilder" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;jkrasnay&#x2F;sqlbuilder</a>
time4teaalmost 12 years ago
Hmm looks a bit like Squiggle SQL, <a href="http://code.google.com/p/squiggle-sql/" rel="nofollow">http:&#x2F;&#x2F;code.google.com&#x2F;p&#x2F;squiggle-sql&#x2F;</a> but less
评论 #5958054 未加载
icedchaialmost 12 years ago
Looks cool, but personally I&#x27;d rather just use regular SQL.
评论 #5957385 未加载