2012-07-20 97 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。