Hi Lukas,
I need to keep the IDs the same as they are stored in the json file. I am
providing the fields to the loaderStep
loaderJSONStep.fields(table.fields()).execute();
As far as I know the
create.execute("SET IDENTITY_INSERT " + stringTableEntry + " " + onOff);
has Session Scope, so it is valid for the same transaction.
In plain JDBC you could do something like this:
http://www.windowsazure.com/en-us/documentation/articles/sql-data-java-how-to-use-sql-database/#to_insert_rows
Can I use the VisitListener to change the insert statement to add the SET
IDENTITY_INSERT flag for each and every statement?
Thanks,
Johannes
Am Freitag, 7. Februar 2014 19:39:21 UTC+1 schrieb Lukas Eder:
>
> Hi Johannes,
>
> There is a pending issue related to this flag:
> https://github.com/jOOQ/jOOQ/issues/1818
>
> So far, I haven't figured out how to generally work around this issue. One
> possible workaround would be for you to implement a VisitListener to
> transform the generated SQL to ignore all inserts to this column. Another
> would be to explicitly specify the fields to be loaded using the
> LoaderJSONStep.fields() method.
>
> But I suspect that you actually want to (re-)load those IDs, right? How
> would this be solved correctly using JDBC? Does this flag "survive" a
> connection / transaction / statement?
>
> Cheers
> Lukas
>
>
> 2014-02-07 16:48 GMT+01:00 <[email protected] <javascript:>>:
>
>> When trying to import data using the JsonLoader into MSSqlServer 2012
>> like this :
>>
>> Table<? extends TableRecord> table = tables.get(tableName);
>> LoaderJSONStep<? extends TableRecord> loaderJSONStep =
>> create.loadInto(table)
>> .onDuplicateKeyIgnore()
>> .onErrorAbort()
>> .commitNone()
>>
>> .loadJSON(jsonDataFiles.get(table.getName()).getInputStream());
>>
>> I get
>>
>> Cannot insert explicit value for identity column in table 'stamm_daten'
>> when IDENTITY_INSERT is set to OFF.
>>
>> errors. I tried to set
>>
>> create.execute("SET IDENTITY_INSERT " + stringTableEntry + " " + onOff);
>>
>> Without success.
>> The generated insert statements contains the column names, so this should
>> also not be a Problem.
>> Any ideas?
>>
>> Thanks
>> Johannes
>>
>> --
>> 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/groups/opt_out.
>>
>
>
--
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/groups/opt_out.