java - JPA in spring-boot project "batch insert" very slow -


hey i'm trying insert 800 rows @onetomany relationships, seems slow. don't quite understand why, since i've read guides said should quick.
hope kind soul tell me if there i've misunderstood , can me increase performance of insertions.

the repository:

@repository public interface footnoterepository extends crudrepository<footnotesentity, long> {      @query("from footnotes number =?1 , footnote_type=?2 order date_start desc,id asc")     public list<footnotesentity> findfootnotebynumberandtype(long number, string transportnumber, pageable pageable); } 

the domainclass:

@autowired private entityrepository entityrepository;  @autowired private footnoterepository footnoterepository; /**  * handles jpa interface  *   * @param  * @return success of operation  */ @transactional private boolean insertupdatefootnoteentities(list<footnotesentity> footnotes) {     boolean success = true;     system.out.println("footnotes: " + footnotes.size());     long start = system.currenttimemillis();     try {         // todo fix below: (does not "commit" deletion")         // footnoterepository.deleteall();          // todo speed optimize         footnoterepository.save(footnotes);      } catch (exception e) {         e.printstacktrace();         success = false;     }     long end = system.currenttimemillis();     system.out.println("time: " + (end - start));     return success; } 

for class i've tried adding batchsize, , using nonspecific repository(basicly entitymanager)'s method: .persist(entity)

'parent' entity class:

@table(indexes = { @index(columnlist = "footnote_number,footnote_type") }, uniqueconstraints = @uniqueconstraint(columnnames = {         "footnote_number", "footnote_type", "date_start" })) @entity(name = "footnotes") @equalsandhashcode(callsuper = false) @data @noargsconstructor @allargsconstructor @builder public class footnotesentity extends baseentity {      @id     @generatedvalue(strategy = generationtype.auto)     @column(name = "footnotes_id")     protected long id;      @column(name = "footnote_number")     protected long number;      @column(name = "footnote_type")     protected string footnotetype;      @column(name = "application_code")     private string applicationcode;      @column(name = "shortdescription", length = 2000)     private string shortdescription;      @column(name = "date_start")     private date startdate;      @column(name = "date_end")     private date enddate;      @onetomany(mappedby = "footnote", fetch = fetchtype.lazy, cascade = cascadetype.all, orphanremoval = true)     @orderby("startdate desc")     protected list<descriptionperiodsentity> descriptionperiods; } 

'child' entity class:

@entity(name = "description_periods") @equalsandhashcode(callsuper = false) @data @noargsconstructor @allargsconstructor @builder public class descriptionperiodsentity {      @id     @generatedvalue(strategy = generationtype.auto)     @column(name = "description_periods_id")     private long id;      @column(name = "date_start")     private date startdate;      @column(name = "date_end")     private date enddate;      @column(name = "description", length = 5000)     protected string description;      @column(name = "languages_id")     protected string languagesid;      @manytoone(fetch = fetchtype.lazy, cascade = cascadetype.persist)     @joincolumn(name = "footnotes_id")     protected footnotesentity footnote;  } 

current runtime: above 4 minutes(276642ms) inserts (796 footnote rows , 900 descriptionperiodes)


Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -