Thx...

So if I use record.from, will the store method do an update as long as the 
id field is not null?
Also, are you saying the using the store method is not the best way to do 
this or?

BTJ

On Monday, September 12, 2016 at 7:44:11 PM UTC+2, Lukas Eder wrote:
>
> Hi BTJ,
>
> Thanks for your enquiry. What you're looking for is something like 
> record.from(Object):
>
> http://www.jooq.org/javadoc/latest/org/jooq/Record.html#from-java.lang.Object-
>
> This is the inverse operation of Record.into(Class) or Record.into(Object).
>
> Note that for historic reasons, when you modify (i.e. set) a Record's 
> primary key value, the store() operation will execute an INSERT statement, 
> as the historic assumption is that primary key values cannot be modified. 
> If you want to use store(), you may need to reset the primary key's changed 
> flag via Record.changed(ID, false):
>
> http://www.jooq.org/javadoc/latest/org/jooq/Record.html#changed-org.jooq.Field-boolean-
>
> Hope this helps.
> Let me know if you have any additional questions and I'm very happy to help
> Lukas
>
> 2016-09-12 13:27 GMT+02:00 BTJ <[email protected] <javascript:>>:
>
>> Just started using JOOQ and so far I really like it but I don't think I 
>> have a complete picture of how to use it yet..
>>
>> At the moment, a store method for me looks like this:
>>
>> public boolean store(Pupil pupil)
>>     {
>>         PupilsRecord record;
>>         if (pupil.getId() == null)
>>         {
>>             record = create.newRecord(PUPILS, pupil);
>>         }
>>         else
>>         {
>>             record = create.fetchOne(PUPILS, 
>> PUPILS.ID.equal(pupil.getId()));
>>             record.setName(pupil.getName());
>>             etc...           
>>         }
>>
>>         return record.store() == 1;
>>     }
>>
>> Is there someway I can auto fill the record instead of manually updating 
>> every field in the record when updating?
>>
>> Any other comments about how to store in JOOQ?
>>
>>
>> Regards,
>>
>> BTJ
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "jOOQ User Group" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups "jOOQ 
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to