Monday, April 2, 2012

Running both EclipseLink and Hibernate JPA 2.0 Implementations

This article details differences in running EclipseLink (2.3) and Hibernate (3.6.8/4.00) primarily using the JPA 2.0 API and native ORM where appropriate.

persist vs merge:

EclipseLink is 30% faster for inserts using persist than Hibernate is for merge.  This may be the fact that the entities continue to be managed in EclipseLink but are persisted as clones by Hibernate.

Hibernate 5450 insertions @ 14.6 tx-inserts/sec to sybase
EclipseLink 4911 insertions @ 18.9 tx-inserts/sec to sybase

Switch persistence.xml provider tags
public class Drug implements Serializable {
    private static final long serialVersionUID = 3132063814489287035L;
    // keep the sequence column name under 30 chars to avoid an ORA-00972   
    @SequenceGenerator(name="JPA_SEQUENCE_DRUG", sequenceName="JPA_DRUG_SEQ", allocationSize=15)
    private Long id;

    private int version;
    @Column(name="compID")//, updatable=false, insertable=false);
    private String compositeID;

    @Column(name="DIN")//, updatable=false, insertable=false)
    private long din;

EclipseLink Logs:
[EL Fine]: 2012-04-02 11:41:34.596--ClientSession(9012544)--Connection(20436132)--Thread(Thread[main,5,main])--INSERT INTO VIG_DRUG (compID, DIN, DRUG_VERSION) VALUES (?, ?, ?)
    bind => [ORTAB, 0, 1]

Hibernate Logs:

Hibernate: select drug0_.DRUG_ID as DRUG1_0_0_, drug0_.compID as compID0_0_, drug0_.DIN as DIN0_0_, drug0_.DRUG_VERSION as DRUG4_0_0_ from VIG_DRUG drug0_ where drug0_.DRUG_ID=?
insert into VIG_DRUG (compID, DIN, DRUG_VERSION) values (?, ?, ?)

Total Pageviews