Digest for jooq-user@googlegroups.com - 4 updates in 2 topics

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Digest for jooq-user@googlegroups.com - 4 updates in 2 topics

http://groups.google.com/group/jooq-user/topics mailing list
Anthony Calce <[hidden email]>: Oct 27 06:52AM -0700

Hey Lukas,
 
Thanks for the quick response. I'll take your suggestion and do it that way
for now
 
On Wednesday, 25 October 2017 11:45:36 UTC-4, Lukas Eder wrote:
Niclas Hedhman <[hidden email]>: Oct 26 07:56PM -0700

For "createTableIfNotExists", doesn't the JDBC Connection already abstract
out what is needed?
 
https://docs.oracle.com/javase/7/docs/api/java/sql/DatabaseMetaData.html#getTables(java.lang.String,%20java.lang.String,%20java.lang.String,%20java.lang.String[])
 
But I don't know if it is reliable enough across JDBC drivers, I don't have
that level of SQL/JDBC experience.
 
Ahhh! I just saw (looking for how to get the JDBC Connection), that the
DatabaseMetaData is already abstracted out in class Meta. For me, that is
good enough for now, as I can always make the check before doing a
createTable and not rely on "ifNotExists". No action required from you, for
_my_ benefit.
 
 
For @Support annotation; If I understand it correctly, it is intended for
when you use the JOOQ data modeling tooling. In my case, everything is
runtime (Table<Record>, and no known types at compile time) and Polygene
has its own modeling design (close to DDD) with Entity, Association,
ManyAssociation and NamedAssociation and quite well manage to hide the
implementation details in the underlying store. The upside is that no JOOQ
details is visible to our users, and I can control exactly what method
calls into JOOQ that is performed (quite few).
 
For reference, we currently support; 'Cassandra', 'File', 'Geode',
'Hazelcast', 'JClouds', 'Jdbm', 'LevelDB', 'Memory', 'MongoDB', 'Java
Preferences', 'Redis', 'Riak' and a SQL Key/Value store. This JOOQ-backed
SQL Entity Store is strategically important to tackle enterprise
environments.
 
I agree that definition of "features" are difficult and might be
counter-productive. Perhaps it is enough to get hold of the JDBC
Connection, getDatabaseMetaData and check the many supportsXyz() methods in
there. Is there a way to get hold of the current connection? I think I can
only do acquire() on the ThreadLocalConnectionProvider but Reflection on
the ThreadLocalTransactionProvider, but that is nasty and would like to
avoid if there is a better way.
 
 
All-in-all, there is not much "meat" left in this thread. I am quite happy
here.
 
 
Niclas
 
On Friday, October 27, 2017 at 12:05:52 AM UTC+8, Lukas Eder wrote:
Lukas Eder <[hidden email]>: Oct 27 07:23AM +0200

Hi Niclas
 
> lang.String,%20java.lang.String[])
 
> But I don't know if it is reliable enough across JDBC drivers, I don't
> have that level of SQL/JDBC experience.
 
Well, for starters, that DatabaseMetaData API is really not reliable,
unfortunately. The jOOQ code generator does not rely on it to reverse
engineer your database, we run our own queries against each databases'
dictionary views.
 
Also, behind the scenes, DatabaseMetaData runs a query (how else would it
fetch the tables?), but that query is not governed by any of jOOQ's
execution lifecycles, which raises many new questions about how this
interaction would be perceived by jOOQ API users.
 
 
> good enough for now, as I can always make the check before doing a
> createTable and not rely on "ifNotExists". No action required from you, for
> _my_ benefit.
 
True, sorry, I should have thought of this. You can manually do that check
on your side.
 
 
> For @Support annotation; If I understand it correctly, it is intended for
> when you use the JOOQ data modeling tooling.
 
I'm not sure what you mean by data modeling tooling. The code generator? In
that case, no: The @Support annotation annotates the DSL API to tell users
which SQL clauses are available in which SQL dialects. For instance, you
could see that createTableIfNotExists is available for these dialects:
 
@Support(value={DB2,FIREBIRD,H2,HSQLDB,MARIADB,MYSQL,ORACLE,POSTGRES,SQLITE,SQLSERVER,SYBASE,VERTICA})
CreateTableAsStep<Record> createTableIfNotExists(Table<?> table)
 
 
 
> counter-productive. Perhaps it is enough to get hold of the JDBC
> Connection, getDatabaseMetaData and check the many supportsXyz() methods in
> there.
 
Oh my :) Don't get me started on those supports() methods...
 
 
> do acquire() on the ThreadLocalConnectionProvider but Reflection on the
> ThreadLocalTransactionProvider, but that is nasty and would like to avoid
> if there is a better way.
 
Yes, you can use DSLContext.connection() and connectionResult():
 
-
https://www.jooq.org/javadoc/latest/org/jooq/DSLContext.html#connection-org.jooq.ConnectionRunnable-
-
https://www.jooq.org/javadoc/latest/org/jooq/DSLContext.html#connectionResult-org.jooq.ConnectionCallable-
Niclas Hedhman <[hidden email]>: Oct 27 01:29PM +0800

> fetch the tables?), but that query is not governed by any of jOOQ's
> execution lifecycles, which raises many new questions about how this
> interaction would be perceived by jOOQ API users.
 
Noted. I only need "getTables()" , and I suspect it is reasonably well
supported. Totally undestand JOOQ's extensive support of all kinds of stuff
that should have been in the Drivers.
 
 
 
 
> @Support(value={DB2,FIREBIRD,H2,HSQLDB,MARIADB,MYSQL,
> ORACLE,POSTGRES,SQLITE,SQLSERVER,SYBASE,VERTICA})
> CreateTableAsStep<Record> createTableIfNotExists(Table<?> table)
 
I meant the POJO conversion support. In my case, JOOQ is not given any
types to inspect and nowhere to put any annotations.
 
 
Is there a way to get hold of the current connection? I think I can only
>> ThreadLocalTransactionProvider, but that is nasty and would like to
>> avoid if there is a better way.
 
> Yes, you can use DSLContext.connection() and connectionResult():
 
Thanks.
 
--
Niclas Hedhman, Software Developer
http://polygene.apache.org - New Energy for Java
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page.
To unsubscribe from this group and stop receiving emails from it send an email to [hidden email].