Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Batch operation doesn't work #187

Open
goodidea-kp opened this issue Mar 23, 2021 · 0 comments
Open

Batch operation doesn't work #187

goodidea-kp opened this issue Mar 23, 2021 · 0 comments

Comments

@goodidea-kp
Copy link

Bug Report

This issue not reported yet

Versions

  • Driver: h2 1.4.200
  • Database: SQL Server
  • Java: 1.8
  • OS:

Current Behavior

I have 2 tables: Table A, Table B.
A has one-to-many on B relationship via FK;
Batch b=c.createBatch(); //<--Creating batch
b.add("insert into A(f1,f2) values('F1','F2')");
b.add("insert into B(f3,key_to_A) values('custom data1',IDENT_CURRENT('A'))");
b.add("insert into B(f3,key_to_A) values('custom data2',IDENT_CURRENT('A'))");
b.add("insert into B(f3,key_to_A) values('custom data3',IDENT_CURRENT('A'))");

b.execute();

After that, data in table A inserted, but no data in table B and no error or warning generated.

I did try to create ALIAS for IDENT_CURRENT, but it didn't work to me as well.

no data
// your stack trace here

Table schema

create table if not exists A (
Id bigint auto_increment primary key,
f1 nvarchar(100),
f2 nvarchar(100)
);
create table if not exists b(
id bigint auto_increment,
key_to_A bigint constraint A_FK references A,
f3 nvarchar(100)
);

Input Code
-- your SQL here;

Steps to reproduce

Java 8.
Create a simple project, set create SQL Server mode.
create a batch with transaction.
add statements to batch
execute, commit, observe no data in table B.

Input Code
// your code here;

Expected behavior/code

Inserted 3 rows into table B

Possible Solution

use a different way to obtain freshly created A.id value to insert into table b? Not sure how to do that.

Additional context

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant