-->
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.  [ 5 posts ] 
Author Message
 Post subject: recovering SessionFactory reference with buildSessionFactory
PostPosted: Sun Nov 23, 2003 1:55 pm 
Newbie

Joined: Sun Nov 23, 2003 1:46 pm
Posts: 15
Hi,

I'm having problems to recover a reference to a SessionFactory using:
Code:
Configuration conf = new Configuration().configure();
sessionFactory = conf.buildSessionFactory();

it get stuck under the call to buildSessionFactory, and oracle DB starts to process like crazy.

I'm using Oracle DB, with tomcat 4.1 with a tomcat DataSource connecting to oracle, then I have the following xml files for hibernate configuration placed under the web-inf/classes folder:

hibernate.cfg.xml
Code:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration
PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">

<hibernate-configuration>
<session-factory>
    <property name="connection.datasource">java:comp/env/sistemaSegurancaDS</property>
    <property name="show_sql">false</property>
    <property name="dialect">net.sf.hibernate.dialect.OracleDialect</property>

<!-- Mapping files -->
<mapping resource="Sistema.map.xml"/>

</session-factory>
</hibernate-configuration>



and also:

Sistema.map.xml

Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping
PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="testestrutshibernate.SistemaDTO" table="tb_sistema">

<id name="id">
<generator class="sequence">
<param name="id">SQ_BD_SISTEMA</param>
</generator>
</id>

<property name="sigla">
<column name="SIGLA"/>
</property>
<property name="nome">
<column name="NOME"/>
</property>
<property name="descricao">
<column name="DESCRICAO"/>
</property>
</class>
</hibernate-mapping>


tx in advance,

_________________
Marcos Maia


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 23, 2003 1:57 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Check the catalina.out log file and possibly increase the log level to debug. Without an error message, we can't help you much.

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


Top
 Profile  
 
 Post subject: that's the problem
PostPosted: Sun Nov 23, 2003 2:10 pm 
Newbie

Joined: Sun Nov 23, 2003 1:46 pm
Posts: 15
Hi,

That's the problem, there's no error message it get stucked and no exception is thrown or error messages are logged, the messages under catalina console get stucked, here goes a copy from the catalina console after get stucked(pls ignore the println messages i put for debugging pourposes);

Quote:
23/11/2003 17:04:25 net.sf.hibernate.cfg.Environment <clinit>
INFO: Hibernate 2.0.2
23/11/2003 17:04:25 net.sf.hibernate.cfg.Environment <clinit>
INFO: hibernate.properties not found
23/11/2003 17:04:25 net.sf.hibernate.cfg.Environment <clinit>
INFO: using CGLIB reflection optimizer
23/11/2003 17:04:25 net.sf.hibernate.cfg.Environment <clinit>
INFO: JVM proxy support: true
23/11/2003 17:04:25 net.sf.hibernate.cfg.Configuration getConfigurationInputStre
am
INFO: Configuration resource: /hibernate.cfg.xml
23/11/2003 17:04:25 net.sf.hibernate.cfg.Configuration addResource
INFO: Mapping resource: Sistema.map.xml
23/11/2003 17:04:25 net.sf.hibernate.cfg.Binder bindRootClass
INFO: Mapping class: testestrutshibernate.SistemaDTO -> tb_sistema
23/11/2003 17:04:25 net.sf.hibernate.cfg.Configuration configure
INFO: Configured SessionFactory: null
passou pela chamada Configuration().configure()
23/11/2003 17:04:25 net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing one-to-many association mappings
23/11/2003 17:04:25 net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing foreign key constraints
23/11/2003 17:04:26 net.sf.hibernate.impl.SessionFactoryImpl <init>
INFO: building session factory
23/11/2003 17:04:26 net.sf.hibernate.dialect.Dialect <init>
INFO: Using dialect: net.sf.hibernate.dialect.OracleDialect
23/11/2003 17:04:26 net.sf.hibernate.util.NamingHelper getInitialContext
INFO: JNDI InitialContext properties:{}
23/11/2003 17:04:26 net.sf.hibernate.connection.DatasourceConnectionProvider con
figure
INFO: Using datasource: java:comp/env/sistemaSegurancaDS
23/11/2003 17:04:26 net.sf.hibernate.impl.SessionFactoryImpl <init>
INFO: Use outer join fetching: true

_________________
Marcos Maia


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 23, 2003 2:21 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
The SessionFactory is fully initialized at this point. I'm not 100% sure, but I think Hibernate doesn't even connect to the database in your code, because that would require operations in a Session.

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


Top
 Profile  
 
 Post subject: I would connect after this
PostPosted: Sun Nov 23, 2003 2:28 pm 
Newbie

Joined: Sun Nov 23, 2003 1:46 pm
Posts: 15
I do in another method, the problem is that it does not return the reference to SessionFactory to allow me to get a session from it after, it get stucked exactly under the call to :

Code:
sessionFactory = conf.buildSessionFactory();


I have a methot to be called later that get a session from sessionfactory:

Code:
      Session sessao = sessionFactory.openSession();
      Transaction transacao = sessao.beginTransaction();
      SistemaDTO dto = new SistemaDTO();
      dto.setId(0);
      dto.setNome(nome);
      dto.setSigla(sigla);
      dto.setDescricao(descricao);
      sessao.save(dto);
      transacao.commit();
      sessao.close();

_________________
Marcos Maia


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