2012-07-20 103 views
0

最近,當我使用EclipsLink 2.0時,遇到了執行持久對象時的性能瓶頸問題。EclipsLink 2.0的性能瓶頸

爲了我曾經有下面的實現更具體的:

@Entity 
@Table(name = "CUSTOMERS") 
public class CustomerEntity implements Serializable { 

@Id 
@GeneratedValue(strategy = GenerationType.AUTO) 
private volatile Long id; 

@Column(nullable = false, unique = true) 
private String name; 

private static final long serialVersionUID = 6952530957072210017L; 

private String custGroup; 
private String address; 
private String nameOfFirstPerson; 
private String contactPerson; 
private String phone; 
private String fax; 
private String email; 
private String comments; 
private String defaultCustomer; 
private volatile boolean delayedPaymentAllowed; 
private volatile long periodOfDelayedPaymentAllowed; 
private volatile boolean restrictionsOnDelayedPayment; 
private volatile double maxAmoutPemittedSom; 
private volatile double maxAmoutPemittedYE; 
private transient String salesPointName; 

@Column(length=25483) 
private HashMap<String, PriceItem> totalBalance; 

@Column(length=25483) 
private HashMap<String, PriceItem> totalBalanceUsd; 

private transient boolean valueChanged = false; 


@OneToMany(mappedBy = "supplier") 
private Collection<PurchaseInvoiceEntity> purchaseInvoices; 

@OneToMany(mappedBy = "receiver") 
private Collection<SalesInvoiceEntity> salesInvoices; 

@OneToMany(mappedBy = "payer") 
private Collection<PayInSlipEntity> payInSlips; 

@OneToMany(mappedBy = "recipient") 
private Collection<PaymentOrderEntity> paymentOrders; 

@OneToMany(mappedBy = "recipient") 
private Collection<WriteOffEntity> writeOffs; 

@ManyToOne() 
private ResponsiblePersonForDebtEntity responsiblePersonForDebt; 

@ManyToOne 
private CustomerGroupEntity customerGroup; 


public CustomerEntity() { 

    valueChanged = false; 
} 
... 
} 

和同時每個我被增加新文檔的實例爲適當的收集,同時插入的文檔的新實例爲I檢測出的表的時間插入文檔需要很長的時間。我在使用netbeans ide 6.9的profiler模塊時遇到了這個問題。其實我正在使用這些藏品來檢查相關文件的空白。

回答

0

爲了解決這個問題我簡單地應用於下述溶液:

  1. 我簡單地去除文檔引用:

    @OneToMany(的mappedBy = 「供應商」) 私人收集purchaseInvoices;

    @OneToMany(mappedBy =「receiver」) private Collection salesInvoices;

    @OneToMany(mappedBy =「payer」) 私人收藏payInSlips;

    @OneToMany(mappedBy =「收件人」) 私人收款paymentOrders;

    @OneToMany(mappedBy =「recipient」) private Collection writeOffs;

從CusotmerEntity:

@Entity 

@Table(name = 「顧客」) 公共類CustomerEntity實現Serializable {

@Id 
@GeneratedValue(strategy = GenerationType.AUTO) 
private volatile Long id; 
@Column(nullable = false, unique = true) 
private String name; 
private static final long serialVersionUID = 6952530957072210017L; 
private String custGroup; 
private String address; 
private String nameOfFirstPerson; 
private String contactPerson; 
private String phone; 
private String fax; 
private String email; 
private String comments; 
private String defaultCustomer; 
private volatile boolean delayedPaymentAllowed; 
private volatile long periodOfDelayedPaymentAllowed; 
private volatile boolean restrictionsOnDelayedPayment; 
private volatile double maxAmoutPemittedSom; 
private volatile double maxAmoutPemittedYE; 
private transient String salesPointName; 
@Column(length = 25483) 
private HashMap<String, PriceItem> totalBalance; 
@Column(length = 25483) 
private HashMap<String, PriceItem> totalBalanceUsd; 
private transient boolean valueChanged = false; 
@ManyToOne() 
private ResponsiblePersonForDebtEntity responsiblePersonForDebt; 
@ManyToOne 
private CustomerGroupEntity customerGroup; 

public CustomerEntity() { 

    valueChanged = false; 
} 
.....} 
  1. 在檢查的文件引用我在編輯或刪除CustomerEntity時使用了JPA查詢。

這個簡單的更改消除了最影響的性能問題。

側面說明:

請在使用性能分析器包括用於包裝方法檢查過(eclipslink爲前。)

0

對於JPA的性能和可伸縮性問題,請閱讀或收聽S「戰略和最佳做法高度可擴展的Java持久性應用程序「,作者:Gordon Yorke。