Returned object result encapsulation, object result Encapsulation
Import tf56.sofa. serializer. jsonGenerateUtil;/*** returned object Result encapsulation * @ athor changmeng. liu * @ date 2014-7-25 * @ version 1.0 * @ update */public class Result {final String SUCCESS = "success"; final String ERROR = "error "; private String count = "";/** response data */private Object data;/** response page * // ** response status */private Boolean status = true; /** Response message */private String message; public Result () {} public Result (Object dat A) {this. data = data;} public Result (String message, Boolean status) {this. set (message, status);} public Result (String message, Boolean status, String count, Object data) {this. set (message, status); this. data = data; this. count = count;} public void set (String message, Boolean status) {this. status = status; this. message = message; this. count = ""; this. data = "";} public void set (String message, Boolean status, String count, Object data) {this. status = status; this. message = message; this. data = data; this. count = count;} public Boolean getStatus () {return status;} public void setStatus (Boolean status) {this. status = status; this. message = this. status? "Successful": "failed"; this. count = ""; this. data = "";} public String getMessage () {return message;} public void setMessage (String message) {this. message = message;} public Object getData () {return data;} public void setData (Object data) {this. data = data;} public String getCommonJson () {return JsonGenerateUtil. getCommonJson (status = true? SUCCESS: ERROR, message, count = null? "": Count, data = null? "": Data );}}
<Pre name = "code" class = "java"> public class InvitationCodeServiceImpl implements InvitationCodeService {@ Autowiredprivate InvitationCodeDao invitationCodeDao; @ Autowiredprivate PartyService partyService; protected Result result = new Result (); protected final Log logger = LogFactory. getLog (getClass ();/*** @ athor changmeng. liu * @ date 2014-7-15 * @ version 1.0 * @ function * @ param * @ update */@ Override Public Result getInvitationCodeByTypeAndId (Map map) {String type = (String) map. get ("type"); String fromid = (String) map. get ("fromid"); if (StringUtils. isEmpty (type) {this. result. set ("type cannot be blank", false); logger. debug (this. result. getMessage (); return this. result;} if (StringUtils. isEmpty (fromid) {this. result. set ("source ID cannot be blank", false); logger. debug (this. result. getMessage (); return this. result;} if (! "Xiao 'er". equals (type )&&! "Member ". equals (type) {this. result. set ("incorrect type", false); logger. debug (this. result. getMessage (); return this. result;} Map <String, Object> paramMap = new HashMap <String, Object> (); paramMap. put ("type", type); paramMap. put ("fromid", fromid); InvitationCode invitationCode = invitationCodeDao. selectByTypeAndId (paramMap); if (invitationCode = null) {this. result. set ("the user's invitation code is not found", true, "", ""); logger. debug (this. result. getMessage (); return this. result;} this. result. set ("successful", true, "1", invitationCode); return this. result ;}}
How to obtain an object returned in the ResultSet?
The ResultSet returns the row set in the database. Is there an object in your database?
In addition to the ResultSet, what other types of objects does JDBC return?
CachedRowSetImpl rowSet = new CachedRowSetImpl (rs); then, the result set is put into the row set object. When the database is closed, the query results will not disappear .. Hope to help you...