Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Need help configuring EclipseLink JPA
Need help configuring EclipseLink JPA [message #386074] Fri, 27 March 2009 21:02 Go to next message
andiqo  is currently offline andiqo Friend
Messages: 32
Registered: July 2009
Member
I need help configuring EclipseLink JPA. Sorry but I am very new to
EclipseLink...

I have a test case which simply commit 11 110 entities in datastore but it
is very slow, and I don't understand why...
** End 1st gen (10) done in 0.053765492s
** End 2nd gen (100) done in 1.397968667s
** End 3rd gen (1000) done in 6.498315777s
** End 4th gen (10000) done in 367.321999793s

Same test execution using OpenJpa (15s vs 375s !) :
** End 1st gen (10) done in 0.049514742s
** End 2nd gen (100) done in 0.33861224s
** End 3rd gen (1000) done in 3.152090838s
** End 4th gen (10000) done in 11.539020043s

I am using EclipseLink 2.0.0M1.
Below my entities and my persistence.xml file (very simple at the moment).

Thanks for your help!
andiqo

@Entity
@Table(name = "NODE")
public class Node implements ICopyable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "ID")
private long id;

@Version
@Column(name = "VERSION")
private int version;

@OneToMany(mappedBy = "to", fetch = FetchType.LAZY, cascade =
CascadeType.ALL, orphanRemoval = true)
private Set<Edge> inputs = new HashSet<Edge>();

@OneToMany(mappedBy = "from", fetch = FetchType.LAZY, cascade =
CascadeType.ALL, orphanRemoval = true)
private Set<Edge> outputs = new HashSet<Edge>();
}

@Entity
@Table(name = "EDGE")
public class Edge {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "ID")
private long id;

@Version
@Column(name = "VERSION")
private int version;

/** The parent */
@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.PERSIST)
@JoinColumn(name = "FROM_ID", nullable = false, updatable = false)
private Node from;

/** The target */
@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.PERSIST)
@JoinColumn(name = "TO_ID", nullable = false, updatable = false)
private Node to;
}

persistence.xml
<properties>
<!-- Database -->
<property name="eclipselink.target-database" value="Auto"/>

<!-- Connection -->
<property name="javax.persistence.jdbc.url"
value="jdbc:postgresql://localhost:5432/jenmo?compatible=7.1" />
<property name="javax.persistence.jdbc.driver"
value="org.postgresql.Driver" />
<property name="javax.persistence.jdbc.user" value="postgres" />
<property name="javax.persistence.jdbc.password" value="dbadmin" />
</properties>
Re: Need help configuring EclipseLink JPA [message #386075 is a reply to message #386074] Sun, 29 March 2009 10:45 Go to previous messageGo to next message
andiqo  is currently offline andiqo Friend
Messages: 32
Registered: July 2009
Member
Sorry for the bad formatting in my previous post:

EclipseLink (persisting 11 110 Nodes):
** End 1st gen (10) done in 0.053765492s
** End 2nd gen (100) done in 1.397968667s
** End 3rd gen (1000) done in 6.498315777s
** End 4th gen (10000) done in 367.321999793s

OpenJpa (persisting 11 110 Nodes):
** End 1st gen (10) done in 0.049514742s
** End 2nd gen (100) done in 0.33861224s
** End 3rd gen (1000) done in 3.152090838s
** End 4th gen (10000) done in 11.539020043s

Do you have an idea what could cause such a difference between OpenJpa and
EclipseLink?

Two differences I have noticed :

* In my Java code

OpenJpa :
OpenJPAEntityManager.persistAll

EclipseLink
for (Object o : pcs) {
em.persist(o);
}

* In the generated SQL

OpenJpa:
SELECT CURRVAL('EDGE_ID_seq')
INSERT IGNORE INTO EDGE (CASCADED, IDX, KIND, VERSION, TO_ID, FROM_ID) VALUES (?,
?, ?, ?, ?, ?) [params=(boolean) true, (null) null, (int) -1, (int) 1,
(long) 1057, (long) 32]

EclipseLink:
select lastval()
INSERT IGNORE INTO EDGE (IDX, CASCADED, KIND, VERSION, FROM_ID, TO_ID) VALUES (?,
?, ?, ?, ?, ?)
bind => [null, true, -1, 1, 5, 101]

Don't know exactly if lastval() use PostgreSQL sequences...

Thanks for your help.

andiqo

P.S. I have set <property name="eclipselink.jdbc.native-sql"
value="true"/> in my persistence.xml
Re: Need help configuring EclipseLink JPA [message #386076 is a reply to message #386075] Sun, 29 March 2009 11:16 Go to previous messageGo to next message
Tom Eugelink is currently offline Tom EugelinkFriend
Messages: 817
Registered: July 2009
Senior Member
It would be interesting to know where the difference come from. But that is more something for James, Doug or Gordon to help with.

andiqo wrote:
> Sorry for the bad formatting in my previous post:
Re: Need help configuring EclipseLink JPA [message #386078 is a reply to message #386074] Mon, 30 March 2009 14:39 Go to previous messageGo to next message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

This is odd, as the performance testing we have done against OpenJPA has
been very favorable towards EclipseLink. From you summer it seems this
issue is you are using SEQUENCE based sequencing in OpenJPA but IDENTITY
in EclipseLink.

Postgres supports both IDENTITY and SEQUENCE sequencing. SEQUENCE
sequence is always recommended as it support preallocation. I would never
recommend IDENTITY sequencing as it does not support preallocation, so can
be a major performance issue. My guess as to what is occurring is that
OpenJPA only support SEQUENCE sequencing it is defaulting the IDENTIY to
SEQUENCE, where as EcliseLink supports both IDENTITY and SEQUENCE, so is
using IDENTITY. So change your classes to use SEQUENCE instead of
IDENTITY.

Also ensure you are using the EclipsLink agent and it is running properly.

Other optimization I would recommend for this case are:
Set,
"eclipselink.jdbc.batch-writing"="JDBC"
"eclipselink.jdbc.batch-writing.size"="1000"
"eclipselink.jdbc.cache-statements"="true"

Also since this seems to be a pure insert test, I would recommend turning
the cache off, or at least off for the class being inserted.

"eclipselink.cache.shared.default"="false"

Note that "eclipselink.jdbc.native-sql" does nothing, as it only effect
how parameters are printed, and parameter binding is the default.

In EclipseLink 1.1 there are also some lower level optimizations. If you
are creating a new EntityManager per transaction, you can use,

"eclipselink.persistence-context.close-on-commit"="true"

This avoids resuming costs.

If you are still having issues please include the full code to how you are
creating your objects and persisting them, how you are creating and
committing your EntityManager, and the full SQL. Your results still seem
odd because they seem to be non-linear. Are the objects that you are
persisting all related? You have cascade persist set, so persist requires
to traverse all related objects. If all of your objects are related and
you call persist on each one, then this is a n^2 issue, the JPA spec
requires this, but perhaps OpenJPA does not obey the spec in this case.
You should either remove the cascade persist, or only call persist on the
root object.

---
James
http://www.nabble.com/EclipseLink---Users-f26658.html


James : Wiki : Book : Blog : Twitter
Re: Need help configuring EclipseLink JPA [message #386080 is a reply to message #386078] Mon, 30 March 2009 20:07 Go to previous messageGo to next message
andiqo  is currently offline andiqo Friend
Messages: 32
Registered: July 2009
Member
> odd because they seem to be non-linear. Are the objects that you are
> persisting all related? You have cascade persist set, so persist requires
> to traverse all related objects. If all of your objects are related and
> you call persist on each one, then this is a n^2 issue, the JPA spec
> requires this, but perhaps OpenJPA does not obey the spec in this case.
> You should either remove the cascade persist, or only call persist on the
> root object.

Bravo you are right: "If all of your objects are related and you call
persist on each one, then this is a n^2 issue".

Thus here are the results:

OpenJpa (GenerationType.IDENTITY):
** End root done in 0.196267613s
** End 1st gen (10) done in 0.049514742s
** End 2nd gen (100) done in 0.33861224s
** End 3rd gen (1000) done in 3.152090838s
** End 4th gen (10000) done in 11.539020043s
** End 5th gen (100000) done in 88.281451693s
End populating done in 103.561279576s

EclipseLink (GenerationType.IDENTITY):
** End root done in 0.059775196s
** End 1st gen (10) done in 0.031361179s
** End 2nd gen (100) done in 0.252552979s
** End 3rd gen (1000) done in 2.413623168s
** End 4th gen (10000) done in 8.81931258s
** End 5th gen (100000) done in 81.196984253s
End populating done in 92.81126931s

EclipseLink (GenerationType.SEQUENCE):
** End root done in 0.079085401s
** End 1st gen (10) done in 0.04394113s
** End 2nd gen (100) done in 0.22403797s
** End 3rd gen (1000) done in 1.592635796s
** End 4th gen (10000) done in 6.186586773s
** End 5th gen (100000) done in 45.696859448s
End populating done in 53.861520179s

Thanks again James, Regards,
andiqo
Re: Need help configuring EclipseLink JPA [message #386081 is a reply to message #386080] Mon, 30 March 2009 20:09 Go to previous message
andiqo  is currently offline andiqo Friend
Messages: 32
Registered: July 2009
Member
Argh, sorry, formatting again!

OpenJpa (GenerationType.IDENTITY):
** End root done in 0.196267613s
** End 1st gen (10) done in 0.049514742s
** End 2nd gen (100) done in 0.33861224s
** End 3rd gen (1000) done in 3.152090838s
** End 4th gen (10000) done in 11.539020043s
** End 5th gen (100000) done in 88.281451693s End populating done in
103.561279576s

EclipseLink (GenerationType.IDENTITY):
** End root done in 0.059775196s
** End 1st gen (10) done in 0.031361179s
** End 2nd gen (100) done in 0.252552979s
** End 3rd gen (1000) done in 2.413623168s
** End 4th gen (10000) done in 8.81931258s
** End 5th gen (100000) done in 81.196984253s
End populating done in 92.81126931s

EclipseLink (GenerationType.SEQUENCE):
** End root done in 0.079085401s
** End 1st gen (10) done in 0.04394113s
** End 2nd gen (100) done in 0.22403797s
** End 3rd gen (1000) done in 1.592635796s
** End 4th gen (10000) done in 6.186586773s
** End 5th gen (100000) done in 45.696859448s
End populating done in 53.861520179s
Previous Topic:change then remove results in exception... why
Next Topic:Getting an exception that is hanging my application with EclipseLink 1.1.0
Goto Forum:
  


Current Time: Fri Apr 26 17:35:32 GMT 2024

Powered by FUDForum. Page generated in 0.03584 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top