For you purpose, just use the JDBCTransactionFactory factory (and do not specify a transaction manager). The in you code:
Code:
Session sess = ...
Transaction tx;
try
{
tx = sess.beginTransaction();
List users = session.find( ... );
for (Iterator itr = users.iterator(); itr.hasNext(); )
{
final my.User user = (my.User)itr.next();
if (statusCheck)
user.enable();
else
user.disable();
}
tx.commit();
}
catch (Exception e)
{
tx.rollback();
throw e;
}
finally
{
sess.close();
}
Again, if you use Hibernate's JTATransactionFactory (i.e., hibernate.transaction.factory_class=net.sf.hibernate.transaction.JTATransactionFactory), Hibernate will delegate all transaction management to the transaction manager you specify. From your description of your system, though, JTA is way overkill for you needs.