java - Better design approach for having a variable in a class not present in Database -


say have class:

class x {   private int a;   private int b;   private int c; }  id & d list well. list<x> result = getresult(id, d); 

now while processing result, have d well. 1 way can think of adding variable d in class x, , make getresult keep appending d.

getresult(id, d) {         foreach id {             x x = databasecall(id);             x.d = d;             result.add(x);         }         return result;     } 

the drawback approach class x no longer has values based on columns in db. there better way?

just add @transient annotation on field should not been persisted.


Comments

Popular posts from this blog

'hasOwnProperty' in javascript -

python - ValueError: No axis named 1 for object type <class 'pandas.core.series.Series'> -

java - How to provide dependency injections in Eclipse RCP 3.x? -