java - InvalidDataAccessApiUsageException: Parameter value element did not match expected type -


i'm trying execute in query using spring data. model looks this:

@entity @table(name = "customer", schema = "public", catalog = "postgres") public class customerentity {     private int id;     private string name;     private int balance;     private string bankid;      @id     @column(name = "id")     public int getid() {         return id;     }      public void setid(int id) {         this.id = id;     }      @basic     @column(name = "name")     public string getname() {         return name;     }      public void setname(string name) {         this.name = name;     }      @basic     @column(name = "balance")     public int getbalance() {         return balance;     }      public void setbalance(int balance) {         this.balance = balance;     }      @basic     @column(name = "bank_id")     public string getbankid() {         return bankid;     }      public void setbankid(string bankid) {         this.bankid = bankid;     } 

and repository interface looks this:

@repository public interface transactionsrepository extends jparepository<transactionsentity, long> {      list<transactionsentity> findbycustomeridin(list<customerentity> customerentities); 

}

the problem when try execute code list<transactionsentity> transactionsentitieslist = transactionsrepository.findbycustomeridin(customerentitieslist);

i exception:

caused by: org.springframework.dao.invaliddataaccessapiusageexception: parameter value element [org.example.domain.admin.customerentity@6a1a2a4] did not match expected type [java.lang.string (n/a)]; nested exception java.lang.illegalargumentexception: parameter value element [org.example.domain.admin.customerentity@6a1a2a4] did not match expected type [java.lang.string (n/a)]

update: transactionsentity.class:

@entity @table(name = "transactions", schema = "public", catalog = "postgres") public class transactionsentity {      private string id;     private string amount;     private string customerid;      @id     @column(name = "id")     public string getid() {         return id;     }      public void setid(string id) {         this.id = id;     }      @basic     @column(name = "amount")     public string getamount() {         return amount;     }      public void setamount(string amount) {         this.amount = amount;     }      @basic     @column(name = "customer_id")     public string getcustomerid() {         return customerid;     }      public void setcustomerid(string customerid) {         this.customerid = customerid;     }      @override     public boolean equals(object o) {         if (this == o) return true;         if (o == null || getclass() != o.getclass()) return false;          transactionsentity = (transactionsentity) o;          if (id != null ? !id.equals(that.id) : that.id != null) return false;         if (amount != null ? !amount.equals(that.amount) : that.amount != null) return false;         if (customerid != null ? !customerid.equals(that.customerid) : that.customerid != null) return false;          return true;     }      @override     public int hashcode() {         int result = id != null ? id.hashcode() : 0;         result = 31 * result + (amount != null ? amount.hashcode() : 0);         result = 31 * result + (customerid != null ? customerid.hashcode() : 0);         return result;     } } 

as says in exception spring expects string because customer_id in transactionentity string, inputting customerentity. instead should input list<string> list of customer ids.

btw shouldn't customer_id int assuming set id of customerentity?

then like

list<integer> customerids = customerentitieslist.stream().map(customerentity::getid).collect(collectors.tolist()); 

Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -