0

I want to create multiple HashMaps with same keys. I fixed this by using @SQLInsert. But now I am getting a Column not found Error, maybe I annotate it wrong?

@ElementCollection
@CollectionTable(name = "BACKUP_INVENTORY", joinColumns =  @JoinColumn(name = "BACKUP_ID"))
@MapKeyJoinColumn(name = "INVENTORY_ID", referencedColumnName = "ID")
@Column(name="AMOUNT")
@SQLInsert(sql="MERGE INTO BACKUP_INVENTORY(BACKUP_ID, INVENTORY_ID,  AMOUT) VALUES (?, ?, ?)")
private Map<InventoryItemIdentifier, Number> backupCount;

Error -

Caused by: org.h2.jdbc.JdbcSQLException: Feld "INVENTORY_ID" nicht gefunden
Column "INVENTORY_ID" not found; SQL statement:
MERGE INTO BACKUP_INVENTORY(BACKUP_ID, INVENTORY_ID,  AMOUT) VALUES (?, ?, ?)[42122-190]

Maybe some one have a better idea to create multiple HashMaps with same Keys?

Example:

HashMap1 : key=abc value=5 ...

HashMap2 : key=abc value=2 ...

roottraveller
  • 7,942
  • 7
  • 60
  • 65
  • Is the column called `AMOUT` or is a typo? If the column is called `AMOUNT` instead, that would explain the error. – Vlad Jan 10 '16 at 15:17
  • Can you get your database system to print a list of the columns in the table? – Vlad Jan 10 '16 at 15:38
  • Do you mean to print out all keys an the right value for it? – th3infinity Jan 10 '16 at 16:12
  • Well, anything that would show us that `INVENTORY_ID` actually exists in the table. Something like a `describe backup_inventory` – Vlad Jan 10 '16 at 16:38
  • I hope i understand it correct. Since Inventory_Id stands for the InventoryItemIdentifier. I printed all entrys of the map out after it was created and all ids and values are correct. I am also able to create a 2. Map and also replace values of the maps but some where late at the startup the error occurs :/ – th3infinity Jan 10 '16 at 17:02

0 Answers0