Hi Joachim,
2013/4/4 Durchholz, Joachim <
Joachim....@hennig-fahrzeugteile.de>:
>> Joachim, let's have a look at this paragraph:
>>
>>> "Oh dear I'll have to learn ALL THAT, that's going to be another
>>> Hibernate experience where I can't know what I'm actually doing, Jooq
>>> promised to be easy and in 1:1 correspondence with SQL but it's not
>>> picking up new features at an alarming rate, where is this whole thing
>>> headed??"
>>
>> What exactly do you mean by "all that"?
>
> On
http://jooq.org, Jooq advertises itself as a tool to generate SQL using a fluent API.
> That's a self-contained task that's small enough to be described in a single sentence.
You're cheating a little bit, or you perform "selective vision" of
some sort :-) There is a very prominent section further down:
What is jOOQ?
===========
jOOQ stands for Java Object Oriented Querying. It combines these
essential features:
- Code Generation: jOOQ generates a simple Java representation of your
database schema. Every table, view, stored procedure, enum, UDT is a
class.
- Active records: jOOQ implements an easy-to-use active record
pattern. It is NOT an OR-mapper, but provides a 1:1 mapping between
tables/views and classes. Between columns and members.
- Typesafe SQL: jOOQ allows for writing compile-time typesafe querying
using its built-in fluent API.
- SQL standard: jOOQ supports all standard SQL language features
including the more complex UNION's, nested SELECTs, joins, aliasing
- Vendor-specific feature support: jOOQ encourages the use of
vendor-specific extensions such as stored procedures, UDT's and
ARRAY's, recursive queries, and many more.
===========
Note that I haven't touched the above list since almost the beginning
of jOOQ in 2009 (maybe I should). Let's have a look at how this
compares to your list of "extra" features
> Okay, that task has hidden complexities, the long list of specifically supported databases is a hint in that direction... but it's still a single, well-defined task
>
> Now when I take a closer look, I see "extra" features like
> - code generation
> - caches
> - object identity issues
> - cross-database compatibility
> - parameter inlining
> - record mapping
> - data type conversion
> - String interning
> - (there may be more, that was just the result of a quick scan of the user manual)
By the original mission of jOOQ 1.x and 2.x, most of the above don't
really qualify as "extra". OK, record mapping and data type conversion
are a bit controversial, maybe.
> Learning how the various SQL features translate to Jooq's DSL and how to get data into and out of it is already quite a task.
> Each of the extra features are undisputedly useful - but only to a subset of Jooq users; yet every Jooq user has to learn them all to master Jooq.
>
> I'm not advocating removal of these features!
> But I'm getting alarmed about the rate at which new features are being accepted into Jooq; maybe just a statement about where the limit is would help.
The rate is actually lower than it used to be with jOOQ 1.x. jOOQ is
really maturing. Not many major features are getting into jOOQ in
minor releases. String interning, for instance is really not a major
feature. You don't have to master this, you can just ignore it for a
long time...
But I see where you're going.
> There might be another remedy, but it would be a LOT of work: Separating Jooq into several libraries.
> A DSL core to create AST-like representations of SQL queries.
> A JDBC part that sends such data structures to JDBC.
> A reveng part that returns a data model.
> Most extras could then be recast as separate libraries that can be attached via an API which is (hopefully) focused; the goal would be that it's possible to roll your own extras. I.e. you could write your own code generator, or use the existing default code generator and modify or subclass it to add class prefixes, without the need to ask for a new Jooq feature. Empower the user :-)
> It's a trade-off, weighing the amount of work to make it happen, more APIs restricting future Jooq evolution, the risk that the whole thing becomes pointless if the APIs evolve into something more complex than the features they support, against the ability to empower the user with a more fine-grained control of what Jooq does. Ultimately, it's not my call to decide that; I'm just pointing out a possible strategy here :-)
Rest assured, that some of this is indeed my long-term strategy. While
the little features are nice and important as well, the long-term
strategy really is to separate concerns to an extent where some of the
core API can be implemented by other implementors, than the "jOOQ
reference implementation". As a matter of fact, even parts of the core
API could be extracted to form a JSR which has been missing for a long
time in the Java ecosystem - in my opinion. A JSR for SQL meta data.
Data types, columns, tables, schemas, catalogs, you name it, in an OO
way (JDBC DatabaseMetaData??? Come ooon!). Such a JSR-backed API could
then also be implemented by Derby, H2, HSQLDB, Liquibase, Flyway, and
lots of other tools that repetitively implement SQL meta data.
Another part is the Record mapping. I am not going to implement the
mapping of jOOQ Records to object trees. Instead, users can implement
their own RecordMappers, passing them to the org.jooq.Result. Once
Java 8 is out, even those RecordMappers will become obsolete, as you
can use Streams and Lambdas to transform List<A> into anything else.
The current sample implementation from Record.into() could indeed be
extracted into another, non-core module, just like the org.jooq.DAO
type and various other components. With this POJO business, my own
laziness and lack of interest is a driving force to make jOOQ users
complain on the Jackson / Modelmapper mailing lists about the
impossibility of useful Record <-> POJO mapping, rather than here :-)
However. Extracting these things takes time. And then, concrete
use-cases matter, too. The perfect, definitive API can never be
touched / changed again. And then. Five years later, it turns out that
it was all wrong. So things evolve step by step, here.
Lots of ideas, so, yes, keep on coming with suggestions. And
contributions, of course! :-)
Cheers
Lukas