Ebaneck / Epita-Java-Project

Introduction to java course project
0 stars 1 forks source link

issues with database schema definition #2

Open Ebaneck opened 6 years ago

Ebaneck commented 6 years ago

Noticed the database schema definition had identity_id as the primary key which is the unique feature... this implies that the UID column should be update-able hence both the select, update and delete prepared statements should affect the UID column. Since the only unique column is IDENTITY_ID

Ebaneck commented 6 years ago

Solution to the above with help from a mate(Binoy)

Add add an model (id) of type int. hence the new clause for updating a single identity will be

PreparedStatement statement = connection.prepareStatement("update IDENTITIES set DISPLAY_NAME=?, EMAIL=?, UID=?" + "where IDENTITY_ID=?"); statement.setString(1, identity.getDisplayName()); statement.setString(2, identity.getEmail()); statement.setString(3, identity.getUid()); statement.setInt(4, identity.getId());

        statement.executeUpdate();
Donabay commented 6 years ago

my update was working great.why did u ask binoy?

Ebaneck commented 6 years ago

this was an entire new issue which concerned the definition of the database schema. he also just noticed that the database definition has field for Identity id which is separate from the UID.

PreparedStatement statement = connection.prepareStatement("update IDENTITIES set DISPLAY_NAME=?, EMAIL=?, UID=?" + "where IDENTITY_ID=?");

The above seems to be the supposed way to make sql queries for updating an identity.

Donabay commented 6 years ago

I had that query