Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/jpa/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jpa EclipsLink 2.0的性能瓶颈_Jpa - Fatal编程技术网

Jpa EclipsLink 2.0的性能瓶颈

Jpa EclipsLink 2.0的性能瓶颈,jpa,Jpa,最近,当我使用EclipsLink 2.0时,我在实现持久化对象时遇到了性能瓶颈问题 更具体地说,我曾经有以下实现: @Entity @Table(name = "CUSTOMERS") public class CustomerEntity implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) private volatile Long id; @Column(nullable = fal

最近,当我使用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;
}
...
}
@实体
@表(name=“客户”)
公共类CustomerEntity实现可序列化{
@身份证
@GeneratedValue(策略=GenerationType.AUTO)
私有可变长id;
@列(nullable=false,unique=true)
私有字符串名称;
私有静态最终长serialVersionUID=6952530957207210017L;
私有字符串组;
私有字符串地址;
私有字符串nameOfFirstPerson;
私人字符串联系人;
私人电话;
私人字符串传真;
私人字符串电子邮件;
私有字符串注释;
私人客户;
允许私人易变布尔延迟付款;
允许长时间延迟付款;
私有易变布尔限制OnDelayedPayment;
私有易失双maxAmoutPemittedSom;
私有易失性双最大值;
私有临时字符串salesPointName;
@列(长度=25483)
私有HashMap totalBalance;
@列(长度=25483)
私人HashMap totalBalanceUsd;
private transient boolean valueChanged=false;
@OneToMany(mappedBy=“供应商”)
私人收款购买发票;
@OneToMany(mappedBy=“接收者”)
私人收款销售发票;
@OneToMany(mappedBy=“付款人”)
私人收款;
@OneToMany(mappedBy=“收件人”)
私人收款人;
@OneToMany(mappedBy=“收件人”)
私人收款减记;
@ManyToOne()
私人负责人;私人负责人;私人负责人;
@许多酮
私有customerGroup实体customerGroup;
公共客户(){
valueChanged=false;
}
...
}

每次在将新文档实例插入表时,我都会在适当的集合中添加新文档的实例,但我发现插入文档的时间太长。我在使用netbeans ide 6.9的探查器模块时遇到了这个问题。实际上,我使用这些集合是为了检查相关文档的空白。

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

  • 我只是删除了文档引用:

    @OneToMany(mappedBy=“供应商”) 私人收款购买发票

    @OneToMany(mappedBy=“接收者”) 私人收款销售发票

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

    @OneToMany(mappedBy=“收件人”) 私人收款人

    @OneToMany(mappedBy=“收件人”) 私人收款减记

  • 从CusotmerEntity:

     @Entity
    
    @表(name=“客户”) 公共类CustomerEntity实现可序列化{

    @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;
    }
     .....}
    
    @Id
    @GeneratedValue(策略=GenerationType.AUTO)
    私有可变长id;
    @列(nullable=false,unique=true)
    私有字符串名称;
    私有静态最终长serialVersionUID=6952530957207210017L;
    私有字符串组;
    私有字符串地址;
    私有字符串nameOfFirstPerson;
    私人字符串联系人;
    私人电话;
    私人字符串传真;
    私人字符串电子邮件;
    私有字符串注释;
    私人客户;
    允许私人易变布尔延迟付款;
    允许长时间延迟付款;
    私有易变布尔限制OnDelayedPayment;
    私有易失双maxAmoutPemittedSom;
    私有易失性双最大值;
    私有临时字符串salesPointName;
    @列(长度=25483)
    私有HashMap totalBalance;
    @列(长度=25483)
    私人HashMap totalBalanceUsd;
    private transient boolean valueChanged=false;
    @ManyToOne()
    私人负责人;私人负责人;私人负责人;
    @许多酮
    私有customerGroup实体customerGroup;
    公共客户(){
    valueChanged=false;
    }
    .....}
    
  • 在检查文档的引用时,我在编辑或删除CustomerEntity时使用了JPA查询
  • 这个简单的更改消除了影响最大的性能问题

    旁注:


    请在使用performance profiler时也检查包方法(例如eclipslink)。

    有关JPA中的性能和可伸缩性问题,请阅读或收听Gordon Yorke的“高伸缩性Java持久性应用程序的策略和最佳实践”