-->
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.  [ 8 posts ] 
Author Message
 Post subject: command line hibernate, no appserver, transactionmanager woe
PostPosted: Mon May 09, 2005 6:37 pm 
Newbie

Joined: Mon May 09, 2005 6:31 pm
Posts: 3
Hi all. I'm jumping into Hibernate for my first time, and my first trick would be to get a command line program working that does some siimple operations. Unfortunately, when I try to start up my main class, i get the exception about the transactionmanager. I've heard people don't have problems w/ this, so it must be my environment.

Libs present are all libs included in the standard hibernate distrib + the oracle driver.

Here's my config file...

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

<hibernate-configuration>
    <session-factory
        name="java:hibernate/SessionFactory">

      <property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
      <property name="hibernate.connection.url">jdbc:oracle:thin:@somewhere:1521:somewhere</property>
        <property name="hibernate.connection.username">sportee1</property>
        <property name="hibernate.connection.password">sportee1</property>
        <property name="hibernatedialect">org.hibernate.dialect.OracleDialect</property>
        <property name="show_sql">true</property>
        <property name="transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
        <property name="hibernate.cache.provider_class">org.hibernate.cache.HashtableCacheProvider</property>
        <property name="hibernate.hbm2ddl.auto">update</property>       
    </session-factory>
</hibernate-configuration>


Hibernate version:

3.0.3

Mapping documents:

none yet

Code between sessionFactory.openSession() and session.close():

Just...

sessionFactory = new Configuration().configure().buildSessionFactory();

Full stack trace of any exception that occurs:

Code:
org.hibernate.HibernateException: No TransactionManagerLookup specified
   at org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:497)
   at com.emeta.solutions.exercise.Exercise$1.initialValue(Exercise.java:34)
   at java.lang.ThreadLocal$ThreadLocalMap.getAfterMiss(Unknown Source)
   at java.lang.ThreadLocal$ThreadLocalMap.get(Unknown Source)
   at java.lang.ThreadLocal$ThreadLocalMap.access$000(Unknown Source)
   at java.lang.ThreadLocal.get(Unknown Source)
   at com.emeta.solutions.exercise.Exercise.getSession(Exercise.java:40)
   at com.emeta.solutions.exercise.CreateCarExercise.main(CreateCarExercise.java:18)
Exception in thread "main"


Name and version of the database you are using:

Oracle 9i

The generated SQL (show_sql=true):

n/a

Debug level Hibernate log excerpt:

All


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 09, 2005 7:03 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
getCurrentSession() is currently not available for use outside of JTA environments.


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 10, 2005 9:03 am 
Newbie

Joined: Mon May 09, 2005 6:31 pm
Posts: 3
steve wrote:
getCurrentSession() is currently not available for use outside of JTA environments.


Then how do i create a session so that I may acctually manipulate mapped objects?


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 10, 2005 10:43 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
um, openSession()


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 10, 2005 10:55 am 
Newbie

Joined: Mon May 09, 2005 6:31 pm
Posts: 3
steve wrote:
um, openSession()


Could you be a little more specific? There is no openSession on the Configuration object and there are 10 classes that have that method name.

Thanks,
-s


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 15, 2005 5:59 am 
Beginner
Beginner

Joined: Sun Apr 24, 2005 4:25 am
Posts: 28
Remove

Code:
name="java:hibernate/SessionFactory"
in your hibernate.cfg.xml if you don't use a JNDI.


Top
 Profile  
 
 Post subject: Re: command line hibernate, no appserver, transactionmanager
PostPosted: Fri Jul 15, 2005 11:11 am 
Newbie

Joined: Wed Apr 27, 2005 1:30 pm
Posts: 7
Hi There,

I had similiar situation where i needed to use hibernate outside a container. i was required to created junit test cases.

I also was new to hibernate. from my experience i would say you should look at Springs Hibernate support you should be able to get up and running with in a few hours on a decent hibernate example.

My Hibernate config file is below for getting database connection. I use my sql but should be fine for oracle

Code:

This is some spring stuff for loading my db properties file
   <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="location">
            <value>classpath:jdbc.properties</value>
        </property>
    </bean>


Code:
    <bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
        <property name="driverClassName"><value>${jdbc.driverClassName}</value></property>
        <property name="url"><value>${jdbc.url}</value></property>
        <property name="username"><value>${jdbc.username}</value></property>
        <property name="password"><value>${jdbc.password}</value></property>
        <property name="defaultAutoCommit"><value>${jdbc.defaultAutoCommit}</value></property
>
</bean>

If you would like to follow this approach it might save you time?

_________________
Tell me, I'll forget. Show me, I may remember. But involve me, and I'll understand.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 15, 2005 11:56 am 
Senior
Senior

Joined: Tue Jun 21, 2005 10:18 am
Posts: 135
Location: South Carolina, USA
I'll assume you know how to get the Configuration object setup (usually just new Configuration() will work). Then:


Code:
SessionFactory sessionFactory = configuration.configure().buildSessionFactory();

Session session = sessionFactory.openSession();


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