wrap loading the decks inside a transaction, and commit the transaction when we're done. hopefully this finally gets rid of the lingering transactions...

This commit is contained in:
Andy Janata 2012-02-20 11:51:03 -08:00
parent 16b36e2c4b
commit 444bcd96e0
2 changed files with 8 additions and 0 deletions

View File

@ -31,6 +31,7 @@ import net.socialgamer.cah.HibernateUtil;
import net.socialgamer.cah.db.BlackCard;
import org.hibernate.Session;
import org.hibernate.Transaction;
/**
@ -49,10 +50,13 @@ public class BlackDeck {
@SuppressWarnings("unchecked")
public BlackDeck() {
final Session session = HibernateUtil.instance.sessionFactory.openSession();
final Transaction transaction = session.beginTransaction();
transaction.begin();
// TODO option to restrict to only stock cards or allow customs
deck = session.createQuery("from BlackCard order by random()").setReadOnly(true).list();
dealt = new ArrayList<BlackCard>();
discard = new ArrayList<BlackCard>();
transaction.commit();
}
/**

View File

@ -31,6 +31,7 @@ import net.socialgamer.cah.HibernateUtil;
import net.socialgamer.cah.db.WhiteCard;
import org.hibernate.Session;
import org.hibernate.Transaction;
/**
@ -49,10 +50,13 @@ public class WhiteDeck {
@SuppressWarnings("unchecked")
public WhiteDeck() {
final Session session = HibernateUtil.instance.sessionFactory.openSession();
final Transaction transaction = session.beginTransaction();
transaction.begin();
// TODO option to restrict to only stock cards or allow customs
deck = session.createQuery("from WhiteCard order by random()").setReadOnly(true).list();
dealt = new ArrayList<WhiteCard>();
discard = new ArrayList<WhiteCard>();
transaction.commit();
}
/**