-->
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.  [ 3 posts ] 
Author Message
 Post subject: Unable to configure Oracle for Hibernate
PostPosted: Sun Jan 13, 2008 4:37 pm 
Newbie

Joined: Sun Jan 13, 2008 4:07 pm
Posts: 1
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3

Mapping documents:
<hibernate-configuration>

<session-factory>
<!-- Database connection settings -->
<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="hibernate.connection.url">jdbc:oracle:thin:@localhost:1525:XE</property>
<!-- property name="hibernate.connection.driver_class" / -->
<property name="hibernate.connection.username">***</property>
<property name="hibernate.connection.password">***</property>
<!-- property name="hibernate.connection.pool_size"></property-->

<!-- dialect for Oracle (any version) -->
<!-- property name="dialect">net.sf.hibernate.dialect.OracleDialect</property -->
<property name="dialect">org.hibernate.dialect.OracleDialect</property>
<property name="hibernate.show_sql">false</property>
<property name="hibernate.use_outer_join">true</property>
<property name="hibernate.transaction.factory_class">net.sf.hibernate.transaction.JTATransactionFactory</property>
<property name="jta.UserTransaction">java:comp/UserTransaction</property>

<mapping resource="events/Event.hbm.xml"/>

</session-factory>

</hibernate-configuration>
Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:
[java] Initial SessionFactory creation failed.org.hibernate.HibernateException: TransactionFactory class not found: net.sf.hibernate.transaction.JTATransactionFactory
[java] Exception in thread "main" java.lang.ExceptionInInitializerError
[java] at util.HibernateUtil.<clinit>(Unknown Source)
[java] at events.EventManager.listEvents(Unknown Source)
[java] at events.EventManager.main(Unknown Source)
[java] Caused by: org.hibernate.HibernateException: TransactionFactory class not found: net.sf.hibernate.transaction.JTATransactionFactory
[java] at org.hibernate.transaction.TransactionFactoryFactory.buildTransactionFactory(TransactionFactoryFactory.java:41)
[java] at org.hibernate.cfg.SettingsFactory.createTransactionFactory(SettingsFactory.java:418)
[java] at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:138)
[java] at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2009)
[java] at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1292)

Name and version of the database you are using:
Oracle 10g XE

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:

Hello,

New to hibernate. Trying to follow the example in the documentation. Got it working with the hsqldb database, however would like to get it working with Oracle. Getting the following exception when trying to run the chapter 1 example. Is there something wrong with the configuration?

I have the Hibernate3 jar file in the path.

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 14, 2008 12:44 pm 
Newbie

Joined: Fri Jan 11, 2008 5:50 am
Posts: 9
Hi,

If you look at the Exception that is generated it tells you what the problem is:

TransactionFactory class not found: net.sf.hibernate.transaction.JTATransactionFactory

Try the following hibernate mapping file:

Code:
<!DOCTYPE hibernate-configuration PUBLIC
   "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
   "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
   <session-factory>

      <property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property>
      <property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
      <property name="hibernate.connection.url">jdbc:oracle:thin:@localhost:1525:XE</property>
      <property name="hibernate.connection.username">your_username</property>
      <property name="hibernate.connection.password">your_password</property>

       <!-- JDBC connection pool (use the built-in) -->
       <property name="connection.pool_size">1</property>
       
      <!-- Important! addendum to what is in text -->
      <property name="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</property>

       <!-- Enable Hibernate's automatic session context management -->
       <property name="current_session_context_class">thread</property>

       <!-- Disable the second-level cache  -->
       <property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>

       <!-- Echo all executed SQL to stdout - You can disable this once you have it working -->
       <property name="show_sql">true</property>
   
   </session-factory>
</hibernate-configuration>


You'll obviously have to replace your_username and your_password with the appropriate username and password for you Oracle Instance.

Hope this helps

Andy


Top
 Profile  
 
 Post subject: Re: Unable to configure Oracle for Hibernate
PostPosted: Mon Jan 14, 2008 5:03 pm 
Newbie

Joined: Mon Jan 14, 2008 10:50 am
Posts: 3
dewaraja wrote:

<hibernate-configuration>

<session-factory>
<!-- Database connection settings -->
<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="hibernate.connection.url">jdbc:oracle:thin:@localhost:1525:XE</property>
<!-- property name="hibernate.connection.driver_class" / -->
<property name="hibernate.connection.username">***</property>
<property name="hibernate.connection.password">***</property>
<!-- property name="hibernate.connection.pool_size"></property-->

<!-- dialect for Oracle (any version) -->
<!-- property name="dialect">net.sf.hibernate.dialect.OracleDialect</property -->
<property name="dialect">org.hibernate.dialect.OracleDialect</property>
<property name="hibernate.show_sql">false</property>
<property name="hibernate.use_outer_join">true</property>
<property name="hibernate.transaction.factory_class">net.sf.hibernate.transaction.JTATransactionFactory</property>
<property name="jta.UserTransaction">java:comp/UserTransaction</property>

<mapping resource="events/Event.hbm.xml"/>

</session-factory>

</hibernate-configuration>


Hi, try to modify:

a) <property name="dialect">
org.hibernate.dialect.Oracle9Dialect
</property>

b) Port 1521 instead of 1525

c) You could remove some parameters in your config file like jta.UserTransaction.

Put here your Oracle JDBC version.

Att.
Edson.


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