• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Migration from Hibernate 2 to Hibernate 3.2.2  RSS feed

 
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Hibernate2
-------------
Configuration File:

<?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>

<!-- MERLIN Session factory instance. -->
<session-factory>
<property name="hibernate.show_sql">false</property>
<property name="hibernate.connection.datasource">jdbc/sampleDS</property>
<property name="hibernate.dialect">net.sf.hibernate.dialect.Oracle9Dialect</property>
<property name="hibernate.jdbc.use_streams_for_binary">true</property>
<property name="hibernate.jdbc.batch_size">0</property>
<property name="hibernate.transaction.factory_class">net.sf.hibernate.transaction.JTATransactionFactory</property>
<property name="jta.UserTransaction">jta/usertransaction</property>
<mapping resource="com/Users.hbm.xml"/>
</session-factory>
</hibernate-configuration>


Session Factory Java:

SessionFactory sessionFactory = new Configuration().configure("/samplehibernate.cfg.xml").buildSessionFactory();
Session sessionObj=sessionFactory.openSession();
Collection coll=sessionObj.find("from com.Users as users");


Hibernate 3.2.2
-----------------
Configuration File


<!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.connection.datasource">jdbc/sampleDS</property>
<property name="dialect">org.hibernate.dialect.Oracle9Dialect</property>
<property name="hibernate.transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>
<property name="show_sql">true</property>
<mapping resource="com/Users.hbm.xml"/>
</session-factory>
</hibernate-configuration>


Session Factory Java:

SessionFactory sessionFactory = new Configuration().configure("/samplehibernate.cfg.xml").buildSessionFactory();
Session sessionObj=sessionFactory.openSession();
Collection coll=sessionObj.createQuery("from com.Users as users").list();


I am getting the following exception:


org.hibernate.TransactionException: Unable to locate UserTransaction to check status
at org.hibernate.transaction.JTATransactionFactory.isTransactionInProgress(JTATransactionFactory.java:102)
at org.hibernate.jdbc.JDBCContext.isTransactionInProgress(JDBCContext.java:187)
at org.hibernate.impl.SessionImpl.isTransactionInProgress(SessionImpl.java:369)
at org.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.java:962)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1114)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)


Any help is appreciated.

Thanks
Sudha
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!