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.  [ 7 posts ] 
Author Message
 Post subject: Hibernate Transaction and test performance
PostPosted: Tue Oct 19, 2004 1:33 pm 
Newbie

Joined: Mon Aug 16, 2004 5:52 am
Posts: 6
Hi all!

I'm a testing one method with multiple threads which is saving simple objetcs.

My session factory is declared final and both session and transaction are gathered in the following class:
[code]
public class SessionOpale {

private static final Log LOG = LogFactory.getLog (SessionOpale.class) ;

private static SessionFactory sessionFactory ;

private Session session ;

private Transaction transaction ;

public SessionOpale() {
}

public void initSession()
throws BaseDeDonneesException {
// Load Configuration and build SessionFactory
sessionFactory = SessionFactoryOpale.getSessionFactory() ;
}

public void openSession()
throws BaseDeDonneesException {
try {
InitialContext ctx=new InitialContext();
DataSource dataSource=(DataSource)ctx.lookup("jdbc/opale");
Connection connection= dataSource.getConnection();
session = sessionFactory.openSession(connection) ;
}
/*catch (HibernateException e) {
// Log l'erreur
LOG.error(ConstantesException.ERREUR_HIBERNATE + " : " + e.getMessage()) ;
// Remonte l'exception
throw new BaseDeDonneesException (ConstantesException.ERREUR_TECHNIQUE,
ConstantesException.TYPE_CRASH) ;
}*/
catch (Exception e) {
// Log l'erreur
LOG.error(ConstantesException.ERREUR_HIBERNATE + " : " + e.getMessage()) ;
// Remonte l'exception
throw new BaseDeDonneesException (ConstantesException.ERREUR_TECHNIQUE,
ConstantesException.TYPE_CRASH) ;
}
}


public void closeSession()
throws BaseDeDonneesException {
try {
session.close() ;
}
catch (HibernateException e) {
// Log l'erreur
LOG.error(ConstantesException.ERREUR_HIBERNATE + " : " + e.getMessage()) ;
// Remonte l'exception
throw new BaseDeDonneesException (ConstantesException.ERREUR_TECHNIQUE,
ConstantesException.TYPE_CRASH) ;
}
catch (Exception e) {
// Log l'erreur
LOG.error(ConstantesException.ERREUR_HIBERNATE + " : " + e.getMessage()) ;
// Remonte l'exception
throw new BaseDeDonneesException (ConstantesException.ERREUR_TECHNIQUE,
ConstantesException.TYPE_CRASH) ;
}
}


public void beginTransaction()
throws BaseDeDonneesException {
try {
transaction = session.beginTransaction() ;
}
catch (HibernateException e) {
// Log l'erreur
LOG.error(ConstantesException.ERREUR_HIBERNATE + " : " + e.getMessage()) ;
// Remonte l'exception
throw new BaseDeDonneesException (ConstantesException.ERREUR_TECHNIQUE,
ConstantesException.TYPE_CRASH) ;
}
catch (Exception e) {
// Log l'erreur
LOG.error(ConstantesException.ERREUR_HIBERNATE + " : " + e.getMessage()) ;
// Remonte l'exception
throw new BaseDeDonneesException (ConstantesException.ERREUR_TECHNIQUE,
ConstantesException.TYPE_CRASH) ;
}
}


public void endTransaction (boolean commit)
throws BaseDeDonneesException {
try {
// Commit la transaction si besoin
if (commit) {
session.flush() ;
transaction.commit() ;
}
else {
transaction.rollback() ;
}
}
catch (HibernateException e) {
// Log l'erreur
LOG.error(ConstantesException.ERREUR_HIBERNATE + " : " + e.getMessage()) ;
try {
// On roll-back la transaction pour


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 19, 2004 2:11 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
can you tell me what is said about the default connection pool in the reference guide?

http://www.hibernate.org/hib_docs/refer ... ernatejdbc

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 20, 2004 1:19 am 
Newbie

Joined: Mon Aug 16, 2004 5:52 am
Posts: 6
Hello Anthony

Yes you are right, my properties file was not the last one I tried to use.
But with c3p0, the problem is still the same and I can't fix it.

Sorry for this leak of information :)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 20, 2004 2:07 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
can you show c3p0 configuration?

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 20, 2004 3:05 am 
Newbie

Joined: Mon Aug 16, 2004 5:52 am
Posts: 6
No pb.
I give you the file and the stack trace.
I hope this could help.
Code:
hibernate.connection.username=opale1
hibernate.connection.password=opale1
hibernate.connection.url=jdbc:oracle:thin:@172.20.12.11:1521:portail
hibernate.connection.driver_class=oracle.jdbc.driver.OracleDriver
hibernate.cglib.use_reflection_optimizer=false
hibernate.dialect=net.sf.hibernate.dialect.OracleDialect
hibernate.jdbc.use_streams_for_binary=true
hibernate.jdbc.batch_size=0
hibernate.connection.provider_class=net.sf.hibernate.connection.C3P0ConnectionProvider
hibernate.c3p0.acquire_increment=1
hibernate.c3p0.idle_test_period=15
hibernate.c3p0.max_size=15
hibernate.c3p0.min_size=3
hibernate.c3p0.max_statements=0
hibernate.c3p0.timeout=1800
hibernate.c3p0.acquire_retry_attempts=100

[code]
java.sql.SQLException: ORA-02391: limite de SESSIONS_PER_USER simultan


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 20, 2004 3:08 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
change
hibernate.c3p0.idle_test_period=15

to
hibernate.c3p0.idle_test_period=1500 (each opened connection will be checked every 1500 seconds) 15 is dangerous for your "test" about performance.

java.sql.SQLException: ORA-02391: limite de SESSIONS_PER_USER simultan

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 20, 2004 6:41 am 
Newbie

Joined: Mon Aug 16, 2004 5:52 am
Posts: 6
Thanks a lot for this precision.
My parameter was wrong and the pool was not well managed.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 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.