[jboss-user] [JBoss Seam] - Re: EntityQuery.refresh() doesn't clear the result list??

ASavitsky do-not-reply at jboss.com
Thu Jul 19 11:27:56 EDT 2007


First, thanks for the pointers. I'll look up the "after transaction" event in the CVS. It must have been a freshly added one, as it's not listed in the Seam 2B docs... yet.

Now, in regards to anonymous wrote : How about using your debugger to find out why ? Sheesh!  where did I say that I didn't use one? Just tried to spare everyone the gory details, as my concern was mainly whether I use the components in a correct way - but since you asked, here goes...

To trace the problem, I used a modified EntityQuery class, with some logging added to the methods that manipulate resultList. Only modified methods are shown for brewity.
package org.jboss.seam.framework;
  | public class EntityQuery extends Query<EntityManager> {
  | 	private static final Log log = LogFactory.getLog(EntityQuery.class);
  | 	private List resultList;
  | 
  | 	private void initResultList() {
  | 		log.warn("Entered initResultList(), ejbql " + getEjbql()
  | 				+ ", hashcode " + this.hashCode() + ", list size "
  | 				+ (resultList == null ? "null" : resultList.size()));
  | 		if (resultList == null) {
  | 			javax.persistence.Query query = createQuery();
  | 			resultList = query == null ? null : query.getResultList();
  | 		}
  | 		log.warn("Exited initResultList(), ejbql " + getEjbql() + ", hashcode "
  | 				+ this.hashCode() + ", list size "
  | 				+ (resultList == null ? "null" : resultList.size()));
  | 	}
  | 	@Transactional
  | 	@Override
  | 	public List getResultList() {
  | 		log.warn("Entered getResultList(), ejbql " + getEjbql() + ", hashcode "
  | 				+ this.hashCode() + ", list size "
  | 				+ (resultList == null ? "null" : resultList.size()));
  | 		if (isAnyParameterDirty()) {
  | 			refresh();
  | 		}
  | 		initResultList();
  | 		try {
  | 			return truncResultList(resultList);
  | 		} finally {
  | 			log.warn("Exited getResultList(), ejbql " + getEjbql()
  | 					+ ", hashcode " + this.hashCode() + ", list size "
  | 					+ (resultList == null ? "null" : resultList.size()));
  | 		}
  | 	}
  | 	@Override
  | 	@Transactional
  | 	public boolean isNextExists() {
  | 		log.warn("Entered isNextExists(), ejbql " + getEjbql() + ", hashcode "
  | 				+ this.hashCode() + ", list size "
  | 				+ (resultList == null ? "null" : resultList.size()));
  | 		return resultList != null && resultList.size() > getMaxResults();
  | 	}
  | 	@Override
  | 	public void refresh() {
  | 		log.warn("Entered refresh(), ejbql " + getEjbql() + ", hashcode "
  | 				+ this.hashCode() + ", list size "
  | 				+ (resultList == null ? "null" : resultList.size()));
  | 		super.refresh();
  | 		resultCount = null;
  | 		resultList = null;
  | 		singleResult = null;
  | 		log.warn("Exited refresh(), ejbql " + getEjbql() + ", hashcode "
  | 				+ this.hashCode() + ", list size "
  | 				+ (resultList == null ? "null" : resultList.size()));
  | 	}
  | }

And here's the log output during the execution of controller's save() method for a new record:

WARN  [org.jboss.seam.framework.EntityQuery] - Entered refresh(), ejbql FROM Account WHERE closed = false AND familyExemption = false AND user = #{principal}, hashcode 10610605, list size 5  
  | WARN  [org.jboss.seam.framework.EntityQuery] - Exited refresh(), ejbql FROM Account WHERE closed = false AND familyExemption = false AND user = #{principal}, hashcode 10610605, list size null  
  | WARN  [org.jboss.seam.framework.EntityQuery] - Entered getResultList(), ejbql FROM Account WHERE closed = false AND familyExemption = false AND user = #{principal}, hashcode 10610605, list size 5  
  | WARN  [org.jboss.seam.framework.EntityQuery] - Entered initResultList(), ejbql FROM Account WHERE closed = false AND familyExemption = false AND user = #{principal}, hashcode 10610605, list size 5

ejbql and hashcode output is mainly to make sure we're dealing with the right query, and that it stays the same object during execution (i.e., not dropped and re-created).

As you can see, refresh() resets the resultList to null all right, yet the next time query gets accessed, it still contains the same old result list (refreshed one would contain 6 items, as one was added)! There are no modifications to resultList in between these calls, as evident from both the logs, and from the breakpoints I've been placing. My suspicions were at the javassist, that with the bytecode enhancement on EntityQuery not all modifications to resultList would be caught by debugger, but since I don't know jack about javassist and bytecode, I didn't investigate those.

Now, I hope I explained that it's not because I'm lazy to use a debugger, that I'm running out of ideas on why is this problem happening?

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4065867#4065867

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4065867



More information about the jboss-user mailing list