-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 9 posts ] 
Author Message
 Post subject: help, performance .
PostPosted: Fri Apr 09, 2004 10:13 am 
Newbie

Joined: Wed Jan 07, 2004 6:13 am
Posts: 13
class Order extends EntityObject {

public void save() {
hibernateSupport.save(this); //if relace hibernate with jdbc here, every things is ok
}

public void setID(String id ) {
this.id = id;
save();
}

public void setName(String value ) {
this.id = id;
save();
}

public void setMemo(String value ) {
this.id = id;
save();
}

public void setAddress(String value ) {
this.id = id;
save();
}

。。。。。。。。
}

class HibernateSupport {
public void save(EntiryObject obj) {
Session sess = factory.openSession();
Transaction tx = null;
try {
tx = sess.beginTransaction();
session.save(obj);
tx.commit();
} catch (Exception e) {
if (tx!=null) tx.rollback();
throw e;
} finally {
sess.close();
}
}
}
System need save and find these entity object frequently, I know these code are very urgly, i dont' want to refactor
them since they are form some stable framework.They can work well in test jsp or test java code, but it will make performance problem
in production env. some times,the system is become very slow , every time it will spent the hibernate code more then 500ms to make
make a save or query operation. When i change the hibernate code to direct jdbc without change the basic structure, everything is ok,
every save call only need 10~50ms. I also find some funny things, in some pc , these code can work well, and in some pc become is very
slow and dircect jdbc is always work well. when i change NIC of slow pc , both of hibernate and dircect jdbc can work well.
Doese it means hibernate make a lot's of request from network ? so is there anyone can give me some advices?
The database is DB28.1, app serve is tomcat 4.1x, and I have used the c3p0 connection pool.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 09, 2004 10:25 am 
Newbie

Joined: Wed Jan 07, 2004 6:13 am
Posts: 13
ps. hibernate is 2.1.1, and never use any relations between objects.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 09, 2004 10:29 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
You have to learn about the different usages of the Session and database transactions. Don't open a Session for every single operation. Come back once you understand the concepts discussed on that page:

http://www.hibernate.org/168.html

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 10, 2004 5:45 am 
Newbie

Joined: Wed Jan 07, 2004 6:13 am
Posts: 13
christian wrote:
You have to learn about the different usages of the Session and database transactions. Don't open a Session for every single operation. Come back once you understand the concepts discussed on that page:

http://www.hibernate.org/168.html

Appreciate your advices, Christian
I know these code are very urgly, but i canno t change them for some reasons. The frame work cannot know how to start and end a session in a transaction. Actually, The framework is not very flexsible, it don't directly call the save method at all, also never use any transaction. I don't dare to change them. i only can change the save method, and choice ejb , jdbc, or hibernate.

So i want to know
1. Since it can work well at jdbcconnection-per-operation pattern, Why it cannot do the same work at hibernate session-per-operation pattern at some pc ?
2. About i mentionted the netcard problem, Could you give me some helpful explain ?

Could you help me ?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 10, 2004 5:50 am 
Newbie

Joined: Wed Jan 07, 2004 6:13 am
Posts: 13
ps. I don't want to use filter to make a session-per-request pattern.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 10, 2004 6:44 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Because a Hibernate Session does much more than a JDBC connection. I also doubt your JDBC solution scales. I don't know what the "netcard" problem is. Make sure you check the SQL execution log of Hibernate (enable show_sql in the configuration) to see what Hibernate executes.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 10, 2004 1:24 pm 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
You need to refactor or to drop this code. Hibernate, JDBC or EJB can not help for performance if you ignore design patterns and use ugly "frameworks".


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 11, 2004 4:22 am 
Newbie

Joined: Wed Jan 07, 2004 6:13 am
Posts: 13
baliukas wrote:
You need to refactor or to drop this code. Hibernate, JDBC or EJB can not help for performance if you ignore design patterns and use ugly "frameworks".

When i use direct jdbc, the performance is ok, but i have to persuade sb to
modify these code. If i have to refactor this framework, i can persuade nobody to do .
netcard maybe is NIC.
I have try to use session-per-request in some part of app, and don't watch the imporvement of performance. Maybe i have to remove the transaction for every operation , The app is a little app, few people use it, although use the ulgy pattern, i don't think it should be so slow.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 11, 2004 4:33 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Don't use Hibernate. Use jdbc.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 9 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.