On a suggestion, I set show_sql to true in the Hibernate configuration and got this stream of queries. I think it's pretty revelatory:
Code:
Hibernate: delete from UserWalkthroughs where SID=?
Hibernate: delete from UserWalkthroughs where SID=?
Hibernate: delete from UserWalkthroughs where SID=?
Hibernate: delete from UserWalkthroughs where SID=?
Hibernate: delete from UserWalkthroughs where SID=?
Hibernate: delete from UserWalkthroughs where SID=?
Hibernate: delete from UserWalkthroughs where SID=?
Hibernate: delete from UserWalkthroughs where SID=?
Hibernate: delete from UserWalkthroughs where SID=?
Hibernate: delete from UserWalkthroughs where SID=?
Hibernate: delete from UserWalkthroughs where SID=?
Hibernate: delete from UserWalkthroughs where SID=?
Hibernate: insert into UserWalkthroughs (SID, UID) values (?, ?)
Hibernate: insert into UserWalkthroughs (SID, UID) values (?, ?)
Hibernate: insert into UserWalkthroughs (SID, UID) values (?, ?)
Hibernate: insert into UserWalkthroughs (SID, UID) values (?, ?)
Hibernate: insert into UserWalkthroughs (SID, UID) values (?, ?)
Hibernate: insert into UserWalkthroughs (SID, UID) values (?, ?)
Hibernate: insert into UserWalkthroughs (SID, UID) values (?, ?)
Hibernate: insert into UserWalkthroughs (SID, UID) values (?, ?)
Hibernate: insert into UserWalkthroughs (SID, UID) values (?, ?)
Hibernate: insert into UserWalkthroughs (SID, UID) values (?, ?)
Hibernate: insert into UserWalkthroughs (SID, UID) values (?, ?)
Hibernate: insert into UserWalkthroughs (SID, UID) values (?, ?)
Hibernate: insert into UserWalkthroughs (SID, UID) values (?, ?)
Hibernate: insert into UserWalkthroughs (SID, UID) values (?, ?)
Hibernate: insert into UserWalkthroughs (SID, UID) values (?, ?)
Hibernate: insert into UserWalkthroughs (SID, UID) values (?, ?)
Hibernate: insert into UserWalkthroughs (SID, UID) values (?, ?)
Hibernate: insert into UserWalkthroughs (SID, UID) values (?, ?)
Hibernate: insert into UserWalkthroughs (SID, UID) values (?, ?)
Hibernate: insert into UserWalkthroughs (SID, UID) values (?, ?)
Hibernate: insert into UserWalkthroughs (SID, UID) values (?, ?)
Hibernate: insert into UserWalkthroughs (SID, UID) values (?, ?)
Hibernate: insert into UserWalkthroughs (SID, UID) values (?, ?)
Hibernate: insert into UserWalkthroughs (SID, UID) values (?, ?)
Hibernate: insert into UserWalkthroughs (SID, UID) values (?, ?)
Hibernate: insert into UserWalkthroughs (SID, UID) values (?, ?)
Hibernate: insert into UserWalkthroughs (SID, UID) values (?, ?)
Hibernate: insert into UserWalkthroughs (SID, UID) values (?, ?)
Hibernate: insert into UserWalkthroughs (SID, UID) values (?, ?)
Hibernate: insert into UserWalkthroughs (SID, UID) values (?, ?)
Hibernate: insert into UserWalkthroughs (SID, UID) values (?, ?)
Hibernate: insert into UserWalkthroughs (SID, UID) values (?, ?)
Hibernate: insert into UserWalkthroughs (SID, UID) values (?, ?)
Hibernate: insert into UserWalkthroughs (SID, UID) values (?, ?)
Hibernate: insert into UserWalkthroughs (SID, UID) values (?, ?)
Hibernate: insert into UserWalkthroughs (SID, UID) values (?, ?)
Hibernate: insert into UserWalkthroughs (SID, UID) values (?, ?)
Hibernate: insert into UserWalkthroughs (SID, UID) values (?, ?)
Hibernate: insert into UserWalkthroughs (SID, UID) values (?, ?)
Hibernate: insert into UserWalkthroughs (SID, UID) values (?, ?)
Hibernate: insert into UserWalkthroughs (SID, UID) values (?, ?)
Hibernate: insert into UserWalkthroughs (SID, UID) values (?, ?)
Hibernate: insert into UserWalkthroughs (SID, UID) values (?, ?)
Hibernate: insert into UserWalkthroughs (SID, UID) values (?, ?)
Hibernate: insert into UserWalkthroughs (SID, UID) values (?, ?)
Hibernate: insert into UserWalkthroughs (SID, UID) values (?, ?)
Hibernate: insert into UserWalkthroughs (SID, UID) values (?, ?)
Hibernate: insert into UserWalkthroughs (SID, UID) values (?, ?)
Hibernate: insert into UserWalkthroughs (SID, UID) values (?, ?)
Hibernate: insert into UserWalkthroughs (SID, UID) values (?, ?)
Hibernate: insert into UserWalkthroughs (SID, UID) values (?, ?)
Hibernate: insert into UserWalkthroughs (SID, UID) values (?, ?)
Hibernate: insert into UserWalkthroughs (SID, UID) values (?, ?)
Hibernate: insert into UserWalkthroughs (SID, UID) values (?, ?)
Hibernate: insert into UserWalkthroughs (SID, UID) values (?, ?)
Hibernate: insert into UserWalkthroughs (SID, UID) values (?, ?)
Hibernate: insert into UserWalkthroughs (SID, UID) values (?, ?)
Hibernate: insert into UserWalkthroughs (SID, UID) values (?, ?)
Hibernate: insert into UserWalkthroughs (SID, UID) values (?, ?)
Hibernate: insert into UserWalkthroughs (SID, UID) values (?, ?)
Hibernate: insert into UserWalkthroughs (SID, UID) values (?, ?)
Hibernate: insert into UserWalkthroughs (SID, UID) values (?, ?)
Hibernate: insert into UserWalkthroughs (SID, UID) values (?, ?)
Hibernate: insert into UserWalkthroughs (SID, UID) values (?, ?)
Hibernate: insert into UserWalkthroughs (SID, UID) values (?, ?)
Hibernate: insert into UserWalkthroughs (SID, UID) values (?, ?)
Hibernate: insert into UserWalkthroughs (SID, UID) values (?, ?)
Hibernate: insert into UserWalkthroughs (SID, UID) values (?, ?)
Hibernate: insert into UserWalkthroughs (SID, UID) values (?, ?)
Hibernate: insert into UserWalkthroughs (SID, UID) values (?, ?)
Hibernate: insert into UserWalkthroughs (SID, UID) values (?, ?)
Hibernate: insert into UserWalkthroughs (SID, UID) values (?, ?)
Hibernate: insert into UserWalkthroughs (SID, UID) values (?, ?)
Hibernate: insert into UserWalkthroughs (SID, UID) values (?, ?)
Hibernate: insert into UserWalkthroughs (SID, UID) values (?, ?)
Hibernate: insert into UserWalkthroughs (SID, UID) values (?, ?)
Hibernate: insert into UserWalkthroughs (SID, UID) values (?, ?)
When I first saw this I thought it might be related to the user being directly available to the jsp as a form backing object, but the inserts still appear after I try evicting it from the session and merging it back in on form submission.
Here's the HQL query for the Sellers with walkthroughs:
Code:
from Seller s where s.hasWalkthrough='true'
And here's the code used within the session:
Code:
userWithSellers = (User) session.load(User.class, id);
userWithSellers.getWalkedSellers().size();
SbxQueries q = SbxQueries.SELLERS_WITH_WALKTHROUGHS;
Query qr = session.createQuery(q.queryAsString());
List l = qr.list();
storeList = new ArrayList<Seller>(l);
Seller.sortByCategory(storeList);
Iterator<Seller> i = storeList.iterator();
TreeSet<Seller> set = new TreeSet<Seller>();
String cat = "-1";
while(i.hasNext()){
Seller k = i.next();
if(!k.getCategory().equals(cat)){
set = new TreeSet<Seller>();
categorizedSellers.put(k.getCategory(), set);
cat = k.getCategory();
}
set.add(k);
sellerMap.put(k.getName(), k);
}
session.evict(userWithSellers);