I can disable identity, foreign key, and unique key generation in the JOOQ generator by setting the following configuration options :
<generate>
<!-- Primary key / foreign key relations should be generated and used.
This is a prerequisite for various advanced features.
Defaults to true -->
<relations>false</relations>
Despite the FK/UK information not being present in the meta-model, what exactly are the consequences of disabling this generation? Which features of JOOQ itself depend upon this information?
Essentially, most of the features documented in the manual's section about CRUD will be unavailable to you:
http://www.jooq.org/doc/latest/manual/sql-execution/crud-with-updatablerecords/
Without knowledge about primary keys, there are no UpdatableRecord
. Ie, you will not be able to write things like:
// This works:
MyTableRecord record =
DSL.using(configuration)
.selectFrom(MY_TABLE)
.where(MY_TABLE.ID.eq(1))
.fetchOne();
// These won't work:
record.store();
record.update();
record.refresh();
record.delete();
// This will still work:
record.insert();
Foreign key information is currently used in only a few places in jOOQ, among others, navigation methods :
BookRecord book = DSL.using(configuration)
.selectFrom(BOOK).where(BOOK.ID.eq(1)).fetchOne();
// This won't work
AuthorRecord author = book.fetchParent(FK_BOOK_AUTHOR);
There are also plans to enhance the code generator to generate such navigation methods ( #4210 ), which means that the following won't work:
// This won't work
AuthorRecord author = book.fetchFkBookAuthor();
Or, the synthetic JOIN ON KEY
clause:
DSL.using(configuration)
.select()
.from(AUTHOR)
.join(BOOK).onKey()
.fetch();
There will be other features depending on the availability of constraint information in the future, but ordinary SQL statements aren't affected.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.