Код: Выделить всё
shop_item
Код: Выделить всё
CREATE TYPE shop_item AS (
id VARCHAR(255),
quantity INTEGER,
quantity_multiplier INTEGER,
price DECIMAL(4, 2)
);
< /code>
shop_orders
Код: Выделить всё
CREATE TABLE IF NOT EXISTS shop_orders (
guild_id BIGINT NOT NULL,
user_id BIGINT NOT NULL,
shop_items shop_item[] NOT NULL,
PRIMARY KEY (guild_id, user_id),
FOREIGN KEY (guild_id) REFERENCES guild_config (guild_id)
ON DELETE CASCADE
);
< /code>
Java SpringBoot DAO Method & Query:
@Override
public void upsert(long guildId, @NotNull ShopOrder shopOrder) {
jdbc.sql("""
INSERT INTO shop_orders (guild_id, user_id, shop_items)
VALUES (?, ?, ?::shop_item[])
ON CONFLICT (guild_id, user_id)
DO UPDATE SET shop_items = EXCLUDED.shop_items;
""")
.param(1, guildId)
.param(2, shopOrder.getUserId())
.param(3, shopOrder.getShopItems())
.update();
}
< /code>
shopOrder.getShopItems()
Код: Выделить всё
ShopItem.class
Код: Выделить всё
public class ShopItem {
private String id;
private int quantity;
private int quantityMultiplier;
private double price;
}
< /code>
The issue I believe is that JdbcClient can't map the List of ShopItem(s) to the one declared as shop_item in the database, But I tried type casting, using ARRAY[?]::shop_item[]
Подробнее здесь: https://stackoverflow.com/questions/794 ... jdbcclient