Hello,

> Background: I fetch some records from the database and then convert them to
> POJOs to make sure no references to the factory/connection/datasource are
> kept alive in the cache. This means the PK column is copied.

If you're using the POJO only for "detaching" records from their
underlying connections, I might have a workaround for you:

- You could serialise / deserialise the Result / Record objects. As
the underlying connection is transient, it will not be restored.
- 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)

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...

> Looking at the code, I haven't found a way to convert a POJO to a record and
> get an UPDATE during store(). Is there one? I'd rather avoid reading the
> record again from the DB to update columns.

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)

As far as I recall, that will indeed set all "changed" flags in the
record's values to true, resulting in an INSERT to be performed. I
wonder what would be a sensible way to indicate to jOOQ, that a record
loaded from a POJO should be considered as an UPDATE candidate, rather
than an INSERT candidate... Any ideas?

Cheers
Lukas

Reply via email to