Fix for #86 - v4 - Remove deprecated QueryListener. You must convert to findIterate() or findVisit()

This commit is contained in:
Rob Bygrave committed 2014-04-20 17:18:13 +12:00
1 parent 811d298355
commit 18d9c53ce3
9 files changed
+13 -161

No files matched your search

@@ -14,7 +14,6 @@ import com.avaje.ebean.Junction;
import com.avaje.ebean.OrderBy;
import com.avaje.ebean.PagingList;
import com.avaje.ebean.QueryIterator;
import com.avaje.ebean.QueryListener;
import com.avaje.ebean.QueryResultVisitor;
import com.avaje.ebean.event.BeanQueryRequest;
import com.avaje.ebeaninternal.api.HashQueryPlanBuilder;
@@ -383,11 +382,6 @@ abstract class JunctionExpression<T> implements Junction<T>, SpiExpression, Expr
return exprList.setFirstRow(firstRow);
}
@Deprecated
public com.avaje.ebean.Query<T> setListener(QueryListener<T> queryListener) {
return exprList.setListener(queryListener);
}
public com.avaje.ebean.Query<T> setMapKey(String mapKey) {
return exprList.setMapKey(mapKey);
}
@@ -12,8 +12,8 @@ import javax.persistence.PersistenceException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.avaje.ebean.QueryIterator;
import com.avaje.ebean.QueryListener;
import com.avaje.ebean.bean.BeanCollection;
import com.avaje.ebean.bean.BeanCollectionAdd;
import com.avaje.ebean.bean.EntityBean;
@@ -23,7 +23,6 @@ import com.avaje.ebean.bean.NodeUsageListener;
import com.avaje.ebean.bean.ObjectGraphNode;
import com.avaje.ebean.bean.PersistenceContext;
import com.avaje.ebeaninternal.api.LoadContext;
import com.avaje.ebeaninternal.api.SpiEbeanServer;
import com.avaje.ebeaninternal.api.SpiExpressionList;
import com.avaje.ebeaninternal.api.SpiQuery;
import com.avaje.ebeaninternal.api.SpiQuery.Mode;
@@ -40,7 +39,6 @@ import com.avaje.ebeaninternal.server.deploy.DbReadContext;
import com.avaje.ebeaninternal.server.el.ElPropertyValue;
import com.avaje.ebeaninternal.server.lib.util.StringHelper;
import com.avaje.ebeaninternal.server.querydefn.OrmQueryProperties;
import com.avaje.ebeaninternal.server.transaction.DefaultPersistenceContext;
import com.avaje.ebeaninternal.server.type.DataBind;
import com.avaje.ebeaninternal.server.type.DataReader;
@@ -135,8 +133,6 @@ public class CQuery<T> implements DbReadContext, CancelableQuery {
private final SpiQuery<T> query;
private final QueryListener<T> queryListener;
private Map<String, String> currentPathMap;
private String currentPrefix;
@@ -277,20 +273,10 @@ public class CQuery<T> implements DbReadContext, CancelableQuery {
this.desc = request.getBeanDescriptor();
this.predicates = predicates;
this.queryListener = query.getListener();
if (queryListener == null) {
// normal, use the one from the transaction
this.persistenceContext = request.getPersistenceContext();
} else {
// 'Row Level Transaction Context'...
// local transaction context that will be reset
// after each 'master' bean is sent to the listener
this.persistenceContext = new DefaultPersistenceContext();
}
this.persistenceContext = request.getPersistenceContext();
this.maxRowsLimit = query.getMaxRows() > 0 ? query.getMaxRows() : GLOBAL_ROW_LIMIT;
this.backgroundFetchAfter = query.getBackgroundFetchAfter() > 0 ? query
.getBackgroundFetchAfter() : Integer.MAX_VALUE;
this.backgroundFetchAfter = query.getBackgroundFetchAfter() > 0 ? query.getBackgroundFetchAfter() : Integer.MAX_VALUE;
this.help = createHelp(request);
this.collection = (BeanCollection<T>) (help != null ? help.createEmpty(false) : null);
@@ -687,13 +673,8 @@ public class CQuery<T> implements DbReadContext, CancelableQuery {
@SuppressWarnings("unchecked")
private void readTheRows(boolean inForeground) throws SQLException {
while (hasNextBean(inForeground)) {
if (queryListener != null) {
queryListener.process((T)getLoadedBean());
} else {
// add to the list/set/map
help.add(collection, getLoadedBean());
}
// add to the list/set/map
help.add(collection, getLoadedBean());
}
}
@@ -21,7 +21,6 @@ import com.avaje.ebean.OrderBy.Property;
import com.avaje.ebean.PagingList;
import com.avaje.ebean.Query;
import com.avaje.ebean.QueryIterator;
import com.avaje.ebean.QueryListener;
import com.avaje.ebean.QueryResultVisitor;
import com.avaje.ebean.RawSql;
import com.avaje.ebean.bean.BeanCollectionTouched;
@@ -69,8 +68,6 @@ public class DefaultOrmQuery<T> implements SpiQuery<T> {
*/
private transient ArrayList<EntityBean> contextAdditions;
private transient QueryListener<T> queryListener;
/**
* For lazy loading of ManyToMany we need to add a join to the intersection
* table. This is that join to the intersection table.
@@ -1016,26 +1013,6 @@ public class DefaultOrmQuery<T> implements SpiQuery<T> {
return this;
}
/**
* Return the findListener is one has been set.
*/
public QueryListener<T> getListener() {
return queryListener;
}
/**
* Set a FindListener. This is designed for large fetches where lots are
* rows are to be processed and instead of returning all the rows they are
* processed one at a time.
* <p>
* Note that the returning List Set or Map will be empty.
* </p>
*/
public DefaultOrmQuery<T> setListener(QueryListener<T> queryListener) {
this.queryListener = queryListener;
return this;
}
public Class<T> getBeanType() {
return beanType;
}
@@ -1044,13 +1021,13 @@ public class DefaultOrmQuery<T> implements SpiQuery<T> {
this.detail = detail;
}
public boolean tuneFetchProperties(OrmQueryDetail tunedDetail) {
return detail.tuneFetchProperties(tunedDetail);
}
public boolean tuneFetchProperties(OrmQueryDetail tunedDetail) {
return detail.tuneFetchProperties(tunedDetail);
}
public OrmQueryDetail getDetail() {
return detail;
}
public OrmQueryDetail getDetail() {
return detail;
}
/**
* Return any beans that should be added to the persistence context prior to
@@ -1244,7 +1221,7 @@ public class DefaultOrmQuery<T> implements SpiQuery<T> {
// their own transaction
return false;
}
if (backgroundFetchAfter > 0 || queryListener != null) {
if (backgroundFetchAfter > 0) {
// run in own transaction as we can't know how long
// the background fetching will continue etc
return true;