首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >EclipsLink 2.0的性能瓶颈

EclipsLink 2.0的性能瓶颈
EN

Stack Overflow用户
提问于 2012-07-20 17:38:50
回答 2查看 91关注 0票数 0

最近,当我使用EclipsLink 2.0时,我遇到了持久化对象实现的性能瓶颈问题。

更具体地说,我曾经有过以下实现:

代码语言:javascript
复制
@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;
}
...
}

当我每次将新文档的实例添加到适当的Collection中,同时将文档的新实例插入到表中时,我检测到插入文档花费的时间太长。我在使用netbeans ide 6.9的profiler模块时遇到了这个问题。实际上,我使用这些集合是为了检查相关文档是否为空。

EN

回答 2

Stack Overflow用户

发布于 2012-07-20 17:40:37

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

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

@OneToMany(mappedBy = "supplier")私有收藏purchaseInvoices;

@OneToMany(mappedBy = "receiver")私有集合salesInvoices;

@OneToMany(mappedBy = "payer")私有收藏payInSlips;

@OneToMany(mappedBy = "recipient")私有集合paymentOrders;

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

在CusotmerEntity中:

代码语言:javascript
复制
 @Entity

@Table(name = "CUSTOMERS")公共类CustomerEntity实现了可序列化{

代码语言:javascript
复制
@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;
}
 .....}

在编辑或删除CustomerEntity.时使用JPA query检查文档引用时使用

这一简单的更改消除了影响最大的性能问题。

附注:

请在使用性能分析器时,也包括对包方法的检查(例如eclipslink)。

票数 0
EN

Stack Overflow用户

发布于 2012-10-05 21:15:22

有关JPA中的性能和可伸缩性问题,请阅读或收听戈登·约克的S"Strategies and Best Practices For Highly Scalable Java Persistence Applications“。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11576757

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档