EclipsLink 2.0的性能瓶颈

时间:2012-07-20 09:38:50

标签: jpa

最近,当我使用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;
}
...
}

并且每当我在将新文档实例插入到表中时将新文档的实例添加到适当的集合中时,我检测到插入文档需要很长时间。当我使用netbeans ide 6.9的探查器模块时,我遇到了这个问题。实际上我正在使用这些集合来检查相关文档的空白。

2 个答案:

答案 0 :(得分:0)

为了解决这个问题,我简单地应用了以下解决方案:

  1. 我只是删除了文档引用:

    @OneToMany(mappedBy =“supplier”) 私人收藏购买发票;

    @OneToMany(mappedBy =“receiver”) 私人收藏salesInvoices;

    @OneToMany(mappedBy =“付款人”) 私人收藏payInSlips;

    @OneToMany(mappedBy =“收件人”) 私人收取付款订单;

    @OneToMany(mappedBy =“收件人”) 私人收藏writeOffs;

  2. 来自CusotmerEntity的

     @Entity
    

    @Table(name =“CUSTOMERS”) 公共类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查询。
    2. 这个简单的更改消除了影响最大的性能问题。

      旁注:

      请在使用性能分析器时包括检查包方法(eclipslink for ex。)

答案 1 :(得分:0)

对于JPA中的性能和可伸缩性问题,请阅读或收听Gordon Yorke撰写的“高度可扩展Java持久性应用程序的策略和最佳实践”。

相关问题