Hi Niclas 2017-10-27 5:56 GMT+03:00 Niclas Hedhman <[email protected]>:
> > 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. > 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. > 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. > 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) > 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. > Oh my :) Don't get me started on those supports() methods... > 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. > 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- -- You received this message because you are subscribed to the Google Groups "jOOQ User Group" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
