java - Performance issue in Hibernate while using session.merge -
i have method :
// method session session = context.gethibernatesession(); transaction tx = session.begintransaction(); private void method(tablealist alist) { for(a : alist) { session.merge(a); } tx.commit(); }
when alist contains more 40 50 objects of table a, it's becoming slow , taking lots of time complete. how resolve issue?
entity a:
/** * persistent class database table. * */ @entity @table(name="a") public class implements serializable { private static final long serialversionuid = 1l; @embeddedid private apk id; @column(name="action_cd") private string actioncd; @column(name="ad_lmt") private bigdecimal adlmt; @temporal( temporaltype.date) @column(name="beg_dt") private date begdt; @column(name="beg_time") private string begtime; @column(name="cst_rma") private bigdecimal cstrma; private string deal; @temporal( temporaltype.date) @column(name="end_dt") private date enddt; @column(name="end_time") private string endtime; @temporal( temporaltype.date) @column(name="ent_dt") private date entdt; @column(name="ent_time") private string enttime; @column(name="itm_cd") private string itmcd; @column(name="pc_tp") private string pctp; @temporal( temporaltype.date) @column(name="pluc_dt") private date plucdt; @column(name="prev_perm_ret") private bigdecimal prevpermret; @column(name="promo_key_value") private string promokeyvalue; @column(name="ret_prc") private bigdecimal retprc; public a() { } public apk getid() { return this.id; } public void setid(apk id) { this.id = id; } public string getactioncd() { return this.actioncd; } public void setactioncd(string actioncd) { this.actioncd = actioncd; } public bigdecimal getadlmt() { return this.adlmt; } public void setadlmt(bigdecimal adlmt) { this.adlmt = adlmt; } public date getbegdt() { return this.begdt; } public void setbegdt(date begdt) { this.begdt = begdt; } public string getbegtime() { return this.begtime; } public void setbegtime(string begtime) { this.begtime = begtime; } public bigdecimal getcstrma() { return this.cstrma; } public void setcstrma(bigdecimal cstrma) { this.cstrma = cstrma; } public string getdeal() { return this.deal; } public void setdeal(string deal) { this.deal = deal; } public date getenddt() { return this.enddt; } public void setenddt(date enddt) { this.enddt = enddt; } public string getendtime() { return this.endtime; } public void setendtime(string endtime) { this.endtime = endtime; } public date getentdt() { return this.entdt; } public void setentdt(date entdt) { this.entdt = entdt; } public string getenttime() { return this.enttime; } public void setenttime(string enttime) { this.enttime = enttime; } public string getitmcd() { return this.itmcd; } public void setitmcd(string itmcd) { this.itmcd = itmcd; } public string getpctp() { return this.pctp; } public void setpctp(string pctp) { this.pctp = pctp; } public date getplucdt() { return this.plucdt; } public void setplucdt(date plucdt) { this.plucdt = plucdt; } public bigdecimal getprevpermret() { return this.prevpermret; } public void setprevpermret(bigdecimal prevpermret) { this.prevpermret = prevpermret; } public string getpromokeyvalue() { return this.promokeyvalue; } public void setpromokeyvalue(string promokeyvalue) { this.promokeyvalue = promokeyvalue; } public bigdecimal getretprc() { return this.retprc; } public void setretprc(bigdecimal retprc) { this.retprc = retprc; } }
apk: @embeddable public class apk implements serializable {
private static final long serialversionuid = 1l; @column(name="sku_num") private string skunum; @column(name="prc_zone_cd") private string prczonecd; @column(name="prc_grp_cd") private string prcgrpcd; @column(name="pc_num") private string pcnum; public apk() { } public string getskunum() { return this.skunum; } public void setskunum(string skunum) { this.skunum = skunum; } public string getprczonecd() { return this.prczonecd; } public void setprczonecd(string prczonecd) { this.prczonecd = prczonecd; } public string getprcgrpcd() { return this.prcgrpcd; } public void setprcgrpcd(string prcgrpcd) { this.prcgrpcd = prcgrpcd; } public string getpcnum() { return this.pcnum; } public void setpcnum(string pcnum) { this.pcnum = pcnum; } public boolean equals(object other) { if (this == other) { return true; } if (!(other instanceof apk)) { return false; } apk castother = (apk)other; return this.skunum.equals(castother.skunum) && this.prczonecd.equals(castother.prczonecd) && this.prcgrpcd.equals(castother.prcgrpcd) && this.pcnum.equals(castother.pcnum); } public int hashcode() { final int prime = 31; int hash = 17; hash = hash * prime + this.skunum.hashcode(); hash = hash * prime + this.prczonecd.hashcode(); hash = hash * prime + this.prcgrpcd.hashcode(); hash = hash * prime + this.pcnum.hashcode(); return hash; } }
Comments
Post a Comment