>> - You could serialise / deserialise the Result / Record objects. As
>> the underlying connection is transient, it will not be restored.
>
> That would work but I'm wary of the performance :-)

Yes, it's not a very elegant workaround

>> - Another option is to use Record.attach() to "detach" records manually:
>>
>> http://www.jooq.org/javadoc/latest/org/jooq/Attachable.html#attach(org.jooq.Configuration)
>
> Can you please update the documentation to say how to *de*tach a record? Can
> I call attach(null)?

I will:
https://github.com/jOOQ/jOOQ/issues/1685

>> I wonder whether there should be a Setting flag to indicate that jOOQ
>> should not automatically "attach" resulting records? While this
>> automatic attachment is convenient for simple use-cases, it's
>> obviously prohibitive when connection and memory-management are
>> important...
>
> In my case, I'm generating "smart" POJOs (which contains some business
> logic), so any changes in the record types wouldn't help.

OK, I see. Well, it might still be useful to some users...

>> How are you loading the POJO into the record? Using Factory.newRecord()?
>>
>> http://www.jooq.org/javadoc/latest/org/jooq/impl/Factory.html#newRecord(org.jooq.Table,
>> java.lang.Object)
>
> record.updateFrom( pojo );
>
> This is a new method which is generated by my modified code generator that
> copies every field.

How is it different from this one?
http://www.jooq.org/javadoc/latest/org/jooq/Record.html#from(java.lang.Object)

>> [...] Any ideas?
>
> Many:
>
> - An update() and insert() method on the record or a parameter in the
> store() method.

That probably makes sense anyway. I have added feature request #1686 for this:
https://github.com/jOOQ/jOOQ/issues/1686

I prefer adding update() and insert() over store() argument flags for
two reasons:

- There is a risk of adding dozens of flags, eventually
- They already exist, internally

> - Make the code in org.jooq.impl.AbstractRecord.into(Table<R>) which resets
> the PK available in a public method

I'd like to keep these things hidden from the public API. Relying on
them will make it difficult to evolve jOOQ's CRUD API, which has quite
a bit of complexity already.

> - Add a field which says whether to INSERT or UPDATE. If it's not set or set
> to AUTO, use the field flags.

I assume you mean adding a field to Record? That would be redundant
with the "changed" info of the PK, although more expressive in its
intent.

> I'm undecided which one would be the best approach.

Among these three, clearly the first one. I'll think about it a bit
more. The question here is whether the decision of updating/inserting
should be done

1. At the moment when store() / insert() / update() is called
2. At the moment when a POJO is loaded into a record

I'd like to explore some options around scenario 2, as well...

Cheers
Lukas

Reply via email to