Am Donnerstag, 9. August 2012 12:21:44 UTC+2 schrieb Lukas Eder:

- 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 :-)
 

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

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

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

Many:

- An update() and insert() method on the record or a parameter in the 
store() method.
- Make the code in org.jooq.impl.AbstractRecord.into(Table<R>) which resets 
the PK available in a public method
- Add a field which says whether to INSERT or UPDATE. If it's not set or 
set to AUTO, use the field flags.

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

Regards,

A. Digulla

Reply via email to