Skip to content

Commit

Permalink
Fix 2: BatchExecqution is no more, maybe because of foreign key being…
Browse files Browse the repository at this point in the history
… also an primariy key or ON UPDATE CASCADE was added
  • Loading branch information
AdrianBalunan committed Apr 15, 2026
1 parent bb4a227 commit 0553bf4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ PRIMARY KEY (`UUID_charities`),
CREATE TABLE IF NOT EXISTS `apbaluna`.`Donations` (
`UUID_Donations` CHAR(36) NOT NULL,
`amount` DECIMAL NOT NULL,
`isAnonymous` TINYINT NOT NULL,
`date` DATE NOT NULL,
`charity_id` CHAR(36) NOT NULL,
`user_id` CHAR(36) NOT NULL,
Expand Down Expand Up @@ -259,12 +260,11 @@ FOREIGN KEY (`User_UUID_User`)
`key_values` TEXT NULL,
`logoBLOB` MEDIUMBLOB NULL,
INDEX `fk_CharityVanity_Charities1_idx` (`UUID_charity` ASC) VISIBLE,
PRIMARY KEY (`UUID_charity`),
CONSTRAINT `fk_CharityVanity_Charities1`
FOREIGN KEY (`UUID_charity`)
REFERENCES `apbaluna`.`Charities` (`UUID_charities`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ON UPDATE CASCADE)
ENGINE = InnoDB;
""";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public CharityRegistry getCharitiesFromDB() {
LEFT JOIN Feedback f ON f.charity_id = c.UUID_charities
LEFT JOIN User u ON f.user_id = u.UUID_user
LEFT JOIN Charity_Categories cc ON cc.Charities_UUID_charities = c.UUID_charities
LEFT JOIN Cat|egories cat ON cat.category_id = cc.Categories_category_id
LEFT JOIN Categories cat ON cat.category_id = cc.Categories_category_id
INNER JOIN CharityVanity cv ON cv.UUID_charity = c.UUID_charities;
""";
Statement stmt = conn.createStatement();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,13 @@ INSERT INTO CharityVanity (UUID_charity, charity_name, charity_link, description
PreparedStatement ps2 = conn.prepareStatement(sql2)) {

for (Charity charity : charities) {
String uuid = charity.getUUID() == null
? UUID.randomUUID().toString()
: charity.getUUID().toString();
String uuid;
if (charity.getUUID() == null) {
uuid = UUID.randomUUID().toString();
System.out.println("API object doesnt have UUID, assigning");
} else {
uuid = charity.getUUID().toString();
}

ps1.setString(1, uuid);
ps1.setString(2, charity.getOrg_number().replaceAll("\\s", ""));
Expand Down

0 comments on commit 0553bf4

Please sign in to comment.