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
Post a Comment