You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is an important issue with Prepared Statements in JDBC that inhibits us from assigning the DEFAULT values to null primary keys that are auto-generated. A reasonable approach would be to modify the table creation procedure to force the use of DEFAULT for AG primary keys. Let me give an example:
This is the table creation database statement:
CREATE TABLE ABC (PK INT PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, B INT);
And this is the corresponding Prepared Statement I suggest to use:
INSERT INTO ABC (A,B) VALUES (DEFAULT, ?);
which is equivalent to:
INSERT INTO ABC (B) VALUES (?);
Of course this would assign to the entry a primary key, that the user wouldn't be aware of upon registration. This naturally leads to the following modification of the interface for the method register() in Component:
public Component register(DeciBell db);
Where the returned value is a clone of the registered component, i.e. contains the value of the primary key assigned to the registered component. The same method interface can also cope with cases where the primary key is provided by the user and is not AG.
The text was updated successfully, but these errors were encountered:
There is an important issue with Prepared Statements in JDBC that inhibits us from assigning the DEFAULT values to null primary keys that are auto-generated. A reasonable approach would be to modify the table creation procedure to force the use of DEFAULT for AG primary keys. Let me give an example:
This is the table creation database statement:
CREATE TABLE ABC (PK INT PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, B INT);
And this is the corresponding Prepared Statement I suggest to use:
INSERT INTO ABC (A,B) VALUES (DEFAULT, ?);
which is equivalent to:
INSERT INTO ABC (B) VALUES (?);
Of course this would assign to the entry a primary key, that the user wouldn't be aware of upon registration. This naturally leads to the following modification of the interface for the method register() in Component:
public Component register(DeciBell db);
Where the returned value is a clone of the registered component, i.e. contains the value of the primary key assigned to the registered component. The same method interface can also cope with cases where the primary key is provided by the user and is not AG.
The text was updated successfully, but these errors were encountered: