In my case the PrimaryKey is generated by the DB, which is a UUID. So to 
avoid this error because PrimaryKey will be null and this error is because 
of that I believe.

Thanks,
Deba

On Thursday, February 27, 2020 at 12:43:35 PM UTC-8, Debapriya Patra wrote:
>
> Hi Lukas,
>
> I am designing a DB where I have the columns below.
>
> [image: Screen Shot 2020-02-27 at 12.34.51 PM.png]
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> There is a nightly build which is basically pulling data from another 
> system and entering records to this DB. I am doing a batch insert of 
> records. 
>
> public boolean createTopicPages(List<TopicPage> topicPages) {
>     List<TopicPageRecord> topicPageRecords = new 
> ArrayList<>(topicPages.size());
>     topicPages.stream().forEach(topicPage -> {
>         TopicPageRecord topicPageRecord = new TopicPageRecord();
>         topicPageRecord.setTaxonomyId(topicPage.getTaxonomyId());
>         topicPageRecord.setCmsName(topicPage.getCmsName());
>         topicPageRecord.setSubject(topicPage.getSubject());
>         topicPageRecord.setClassification(topicPage.getClassification());
>         topicPageRecord.setEntryName(topicPage.getEntryName());
>         topicPageRecord.setStatus(topicPage.getStatus());
>         topicPageRecord.setEntryUpdated(topicPage.getEntryUpdated());
>         topicPageRecord.setEntryPublished(topicPage.getEntryPublished());
>         topicPageRecords.add(topicPageRecord);
>     });
>     int[] execute = dsl.batchInsert(topicPageRecords).execute();
>     return execute.length > 0;
> }
>
>
> Now the problem is, when every time pull records and trying to insert into 
> the DB , there will be exiting entries already in the DB. I wanted to 
> either ignore or update the existing records. 
> If there is a change to either *entry_updated OR status * for any of the 
> existing records in DB then I wanted to update that record with the new 
> status and entry_updated value. Otherwise ignore those existing records and 
> just insert the new ones.
>
> In my DB* cms_name, taxonomy_id & subject* are unique columns. 
>
> Can you please let me know how will I solve this problem using Jooq query 
> ? I was reading lot of blogs where people are talking about *upsert* 
> solutions which you have provided but in my case its a batch insert I am 
> doing so in that case how Jooq will help me here.
>
> NOTE: I use Postgres DB for my application.
>
> Thanks,
> Deba
>

-- 
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].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jooq-user/5b15619b-8937-43d5-a52d-55d0b4caf651%40googlegroups.com.

Reply via email to