1

I've created a Ignite table via defining two columns as primary key (PK). When I tried to insert the data its failing with duplicate key error. PK defined on type and id column.

0: jdbc:ignite:thin://node1.example.com> insert into balance (type,amount,currency,asof,id) values ('Current Balance',20000.1,'INR','2020-04-07 00:00:00.000','1009230183926');
1 row affected (0.036 seconds)

0: jdbc:ignite:thin://node1.example.com> insert into balance (type,amount,currency,asof,id) values ('Current Balance',30000,'INR','2020-04-07 00:00:00.000','1009230183926');
Error: Duplicate key during INSERT [key=SQL_PUBLIC_BALANCE_4791140f_63cb_4663_8c02_58f14073ff0c_KEY [idHash=1321771843, hash=-1614321497, TYPE=Current Balance, ID=1009230183926]] (state=23000,code=4001)
java.sql.SQLException: Duplicate key during INSERT [key=SQL_PUBLIC_BALANCE_4791140f_63cb_4663_8c02_58f14073ff0c_KEY [idHash=1321771843, hash=-1614321497, TYPE=Current Balance, ID=1009230183926]]

Does Ignite support composite key like any other RDBMS? How I can resolve this.

  • Can you show your CREATE TABLE statement or a cache cfg? Do you use cache API or it's about jdbc driver only? – Alexandr Shapkin May 02 '20 at 19:56
  • 3
    If the PK is composed of `type` and `id`, then the behavior is correct - values are indeed the same in the two lines you provided ('Current Balance' and '1009230183926' respectively). Are you sure there is an issue? – Valentin Kulichenko May 02 '20 at 21:58
  • 3
    P.S. Composite primary key is supported by Ignite, and it looks like you defined it correctly. The printed key contains both `type` and `id` columns: `key=SQL_PUBLIC_BALANCE_4791140f_63cb_4663_8c02_58f14073ff0c_KEY [idHash=1321771843, hash=-1614321497, TYPE=Current Balance, ID=1009230183926]` – Valentin Kulichenko May 02 '20 at 21:59
  • @ Alexandr Shapkin @Valentin Kulichenko I got the concepts in wrong way. Its now clear to me. Thanks for your help. – sandipbhowmik May 05 '20 at 18:59

0 Answers0