> Again, if my primary key is a user name, an email, a region or some shipping
> code, I'd be unable to insert...

True. In some degrees of relational normalisation, this is quite expected.

> I'd prefer having a factory method with some DSL such as
> TAuthorRecord author = Factory.updateRecord(T_AUTHOR).wherePk( AuthorId );

In a less fluent way, this is already possible today:

--------------------------------------------------
UpdateQuery update = Factory.updateQuery(T_AUTHOR);
update.setRecord(author);
update.addConditions(T_AUTHOR.ID.equal(author.getId());
update.execute();

// or...

Factory.executeInsert(T_AUTHOR, author);
Factory.executeUpdate(T_AUTHOR, author, T_AUTHOR.ID.equal(author.getId()));
--------------------------------------------------

The above API originates from very early days of jOOQ. In the mean
time, I guess there is some redundancy in it (e.g. having to pass the
table). I guess there is some room for improvement there. I'll track
such improvements as #1692:
https://github.com/jOOQ/jOOQ/issues/1692

> rather than letting some obscure logic decide.
> Compared to record-level methods like markAsNew(), storeAsUpdate, storeAsNew
> this would not confuse internal states, dirty fields tracking and such.

Well, it might still be useful to actually add Record.insert() and
Record.update() methods, in case users do want to reset dirty fields
tracking.

Reply via email to