java - issue while converting BigDecimal to Integer -


i'm facing problem while converting big decimal integer. process description is, first sending list of integers dao method validate whether integers valid proceed further. valid list of integers processed in place.

core process

list<integer> payments = dao.checkstatus(payments); //payments list of    integer if(payments!=null){     //do other operation     dao.changestatus(payments);  //here payments list of integer  got above 

dao method implementation

  1. checkstatus(list<integer> payments){     list<integer> finalpayments = null;     //i have hibernate query details database     string hql_query = "select a.py t_status a.status = 4 ,  (a.py=:payments)";     query query = session.createquery(hql_query);     finalpayments = query.list();     return finalpayments; } 

    in database py column bigdecimal one. in table defined number. type. while execution of query i'm getting bigdecimal values finalpayments list. there no error/exception. bigdecimal value returned properly.

    in core process, after 1st method:

    if(payments!=null){ //we're doing list of integer payments right? //it passed 2nd method. 
  2. changestatus(list<integer> finalpayments){     string hql_query="update t_status set a.status = 6 (a.py:=finalpayments)";     query query = session.createquery(hql_query);     query.setparameter("finalpayments", finalpayments);  //here i'm getting error     list<integer> paymentsafter = query.list(); } 

    the error is: cannot cast java.math.bigdecimal java.lang.integer

    between 1st , 2nd method tried convert bigdecimal integer. can't convert integer list integer again.but need in format of integer process 2nd method. please on this..

i'm not sure understand question if have bigdecimal , want integer can use either intvalue of intvalueexact.

e.g.

list<bigdecimal> decimals = ... list<integer> ints = decimals.stream().map(bigdecimal::intvalue).collect(collectors.tolist()); 

Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -