[hibernate-issues] Why sometimes the Transaction is required for Query, sometimes not ?

Miroslav Nachev miro at space-comm.com
Fri Feb 23 13:01:49 EST 2007


Why sometimes the transaction is required for query, sometimes the 
transaction is not required?
Where and what is the logic for that?
In my opinion the transaction is not required for any query, but today I 
use Oracle 10g where was impossible to make Query without transaction:
public static List<Order> getOrders()
{
Session session = getSessionFactory().getCurrentSession();
Transaction transaction = session.beginTransaction();
try
{
List<Order> orders = (List<Order>)session.createQuery("from Order").list();
transaction.commit();
transaction.begin();
return orders;
}
catch(Throwable ex)
{
transaction.rollback();
session.close();
ex.printStackTrace();
throw new RuntimeException(ex);
}
}

I am looking in other projects which use MySQL and Derby where the 
transaction is not required for query.
Now I am trying to make the same situation for Derby but the query is 
processing fine without transaction.

Can somebody tell me where is the true and is it possible to configure 
Hibernate when use Oracle to make Query without using transactions?

Thank you in advance.


Regards,
Miro
-------------- next part --------------
A non-text attachment was scrubbed...
Name: miro.vcf
Type: text/x-vcard
Size: 319 bytes
Desc: not available
Url : http://lists.jboss.org/pipermail/hibernate-issues/attachments/20070223/1696982b/attachment.vcf 


More information about the hibernate-issues mailing list