0

I have an Entity which has a HashMap<String, Integer> in it. My Product.java Entity file -

import java.util.HashMap;
import java.util.Objects;

import javax.persistence.Entity;
import javax.persistence.Id;

@Entity
public class Product {

    @Id
    private int productCode;
    
    private String name;
    private String brand;
    private String description;
    private int price;
    private HashMap<String, Integer> deliverableTo;

The deliverableTo has a HashMap<String, Integer>. I am writing this query -

INSERT INTO `product-browser`.`product` (`product_code`, `brand`, `deliverable_to`, `description`, `name`, `price`) VALUES ('101', 'nVidia', ('Mumbai', '3'), 'Graphics Card', 'RTX 3060', '30000')

I have also tried -

INSERT INTO `product-browser`.`product` (`product_code`, `brand`, `deliverable_to`, `description`, `name`, `price`) VALUES ('101', 'nVidia', {'Mumbai': '3'}, 'Graphics Card', 'RTX 3060', '30000')

I do not know how to enter a hashmap value into mysql table. I have product-browser database with product table in it.

Here is a screenshot to make it more clear how the table looks like and what I am trying to do. Product Table

Innomight
  • 556
  • 3
  • 15

0 Answers0