使用實體管理器JPA與eclipse鏈接2.3 & Derby db和我有10個實體的模型和我需要存儲的每個實體1000個記錄,這個過程大約70秒。我已經測試了10個實體的同一個模型,但是使用100個記錄提交的所有過程花費大約1.2秒,這非常棒。實體管理器提交的性能不佳 - 指數
瓶頸是entityManager.getTransaction().commit();
我堅持所有的數據後,我只做了一次,承諾從所有過程中獲得更多的95%。 當我使用JVM監視我潛水的承諾,我看到這個類的一個負責幾乎所有的提交時間,該類是org.eclipse.persistence.mappings.ManyToManyMapping
http://www.eclipse.org/eclipselink/api/1.0/org/eclipse/persistence/mappings/ManyToManyMapping.html
我的實體和模型沒有按」 t有任何多對多的關係或使用任何很多的註釋,什麼可能是指數行爲的原因?
我注意到,當我刪除這兩個實體的時間節省了85%
什麼是錯的這個實體
導航是從一個人具有基數1到標題獎是有基數N個即一個人可以有多個獎項...
@javax.persistence.Entity
@javax.persistence.Table(name = "a3_Person")
public class Person {
@javax.persistence.Id
@javax.persistence.Column(length = 20)
//// Id;
private String person_id;
public String getPerson_id() { return this.person_id; }
public void setPerson_id(String person_id) { this.person_id = person_id; }
@javax.persistence.Column(length = 30)
//// Name;
private String person_name;
public String getPerson_name() { return this.person_name; }
public void setPerson_name(String person_name) { this.person_name = person_name; }
//// Awards;
private List<TitleAward> person_awards;
public List<TitleAward> getPerson_awards() { return this.person_awards; }
public void setPerson_awards(List<TitleAward> person_awards) { this.person_awards = person_awards; }
}
@javax.persistence.Entity
@javax.persistence.Table(name = "a3_TitleAward")
public class TitleAward {
@javax.persistence.Id
@javax.persistence.Column(length = 20)
//// Id;
private String titleaward_id;
public String getTitleaward_id() { return this.titleaward_id; }
public void setTitleaward_id(String titleaward_id) { this.titleaward_id = titleaward_id; }
@javax.persistence.Column(length = 30)
//// Type;
private String titleaward_type;
public String getTitleaward_type() { return this.titleaward_type; }
public void setTitleaward_type(String titleaward_type) { this.titleaward_type = titleaward_type; }
@javax.persistence.Column(length = 30)
//// Category;
private String Cateeheihbadc;
public String getCateeheihbadc() { return this.Cateeheihbadc; }
public void setCateeheihbadc(String Cateeheihbadc) { this.Cateeheihbadc = Cateeheihbadc; }
@javax.persistence.Column()
//// Year;
private String titleaward_year;
public String getTitleaward_year() { return this.titleaward_year; }
public void setTitleaward_year(String titleaward_year) { this.titleaward_year = titleaward_year; }
@javax.persistence.Column()
//// Won;
private Boolean titleaward_won;
public Boolean getTitleaward_won() { return this.titleaward_won; }
public void setTitleaward_won(Boolean titleaward_won) { this.titleaward_won = titleaward_won; }
//// Person;
private Person Pers_fhfgdcjef;
public Person getPers_fhfgdcjef() { return this.Pers_fhfgdcjef; }
public void setPers_fhfgdcjef(Person Pers_fhfgdcjef) { this.Pers_fhfgdcjef = Pers_fhfgdcjef; }
}
謝謝詹姆斯!我已經添加了兩個實體(我編輯了這兩個實體的帖子),這些問題可以讓你看到什麼是錯誤的定義,因爲我有不同的實體與1到N,在同一個模型中不會導致性能不佳, – 2013-04-30 14:25:07
嗯,你有一個ManyToMany,person_awards,因爲這是任何實體集合的默認值。你應該使用@OneToMany(mappedBy =「Pers_fhfgdcjef」)。但要知道性能問題是什麼,您需要包含您正在運行的代碼以及SQL日誌或配置文件的樣本。 – James 2013-05-01 13:04:26
@ James- im使用netfilix文件有同樣的問題。它實際上是什麼意思,實際上,如果你不添加註釋實體與列表JPA翻譯它默認多對多?btw你怎麼看到這個文件在吉恩帖子有很多很多?謝謝! – 2013-05-01 15:39:57