Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Reading entity beans from Glassfish too slow
Reading entity beans from Glassfish too slow [message #527718] Fri, 16 April 2010 08:45 Go to next message
No real name is currently offline No real nameFriend
Messages: 5
Registered: April 2010
Junior Member
Hi all,

I'm a newbie in Eclipselink and at this time I'm doing some tests. I have created a simple project with 3-layer architecture - swing client, glassfish server and mysql database. The test is simple - in the database I've created a small table (5 columns - id and varchars) with no relations. Using netbeans 6.8 I have created an entitybean like this:

@Entity
@Table(name = "test")
@NamedQueries ...
public class Test implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Basic(optional = false)
@Column(name = "id")
private Integer id;
...

and a sessionbean with findAll:
public List findAll() {
return em.createNamedQuery("Test.findAll").getResultList();
}

I have inserted 10 000 rows into this table, then I've started a simple swing client on second computer (using JWS). Getting the list of the entites takes about 15 seconds.
Then I've created another method findAllNative:
public List findAllNative() {
return em.createNativeQuery("select * from test").getResultList();
}
and on the client side I have mapped the result list to my own class (is a POJO class with getters and setters). This takes about 2 seconds! (loading and mapping)

So my question is - what I'm doing wrong? I know, that the mapping slows the performance, but so much?

My env: java 1.6.0.18_b07, Netbeans 6.8, Ecplipselink 2.0.0 (v20091127-r5931), Glassfish 2.1.1 ((v2.1 Patch06)(9.1_02 Patch12)) (build b31g-fcs), connection 1Gbps, both computers are dualcores with 4GB RAM, Win XP / Win 7.

Thank you and sorry for my english, I'm not a native speaker Smile

Thomas

[Updated on: Fri, 16 April 2010 10:08]

Report message to a moderator

Re: Reading entity beans from Glassfish too slow [message #528148 is a reply to message #527718] Mon, 19 April 2010 14:18 Go to previous messageGo to next message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

My guess would be you have a EAGER OneToOne or ManyToOne relationship in your Test class. This requires EclipseLink to fetch each of these, one by one.

You can instead mark it LAZY, or use a "join fetch" or "batch read".

Please include the full source to your class.

Also enable logging and see what is occurring, include the SQL trace.

Also measure the server performance with the client performance. Is the server taking longer or just the client? It could be a serialization issue.


James : Wiki : Book : Blog : Twitter
Re: Reading entity beans from Glassfish too slow [message #528602 is a reply to message #528148] Wed, 21 April 2010 08:54 Go to previous messageGo to next message
No real name is currently offline No real nameFriend
Messages: 5
Registered: April 2010
Junior Member
Hi,
thank you for reply!

To the first point - there is no relationship, the whole entityclass:
@Entity
@Table(name = "test")
@NamedQueries(...)
public class Test implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Basic(optional = false)
    @Column(name = "param1")
    private String param1;
    @Basic(optional = false)
    @Column(name = "param2")
    private String param2;
    @Basic(optional = false)
    @Column(name = "param3")
    private String param3;
    @Basic(optional = false)
    @Column(name = "param4")
    private String param4;
    @Lob
    @Column(name = "param5")
    private String param5;
... // getters and setters
}


I have made some measurements and I think the problem is in the deserialization on client side, because:
- it's only 9 MB of data transported through network, which is very fast -> sending data to client takes only 2 seconds
- after the data are received, the client cpu load goes to 50% (it's dualcore, so I think one whole core is used) for the rest of time...
- at this time I don't set the data to the gui, so there is no gui delay (only a "done" message with time is showed)

The call of the session bean on client side:
Context c = new InitialContext();
return (TestSessionRemote) c.lookup("java:comp/env/TestSessionBean");

The client contains the ejb jar, so it has access to ejb classes.

Is there any way for tunning the deserialization of the entity beans? I don't understand, why it takes needs so much performance on client side.

Thomas
Re: Reading entity beans from Glassfish too slow [message #528617 is a reply to message #528602] Wed, 21 April 2010 10:00 Go to previous message
No real name is currently offline No real nameFriend
Messages: 5
Registered: April 2010
Junior Member
So I have found two solution:

1. Use manual serialization described in:
http://forums.java.net/jive/thread.jspa?messageID=394388

This works great! The time goes down from 14-15 seconds to 0,2! Actually I have a question - why? Why I need to use such manual workaround?

2. Not tested, but there is an option -Dcom.sun.corba.ee.encoding.ORBEnableJavaSerialization, which should be setted to true. But actually I don't know how to set this in my project - swing client is runned using webstart. The JNLP file is generated by glassfish and I don't know how to say the client run with this jvm option.

The second solution is more cleaner, so if somebody knows, how to set this up, please tell me.

Thank you

Thomas
Previous Topic:How to approach data tracking?
Next Topic:COMMIT is not allowed in a subordinate session
Goto Forum:
  


Current Time: Mon Nov 24 09:44:29 GMT 2014

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

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