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