mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Merge in v4 code changes
This commit is contained in:
@@ -12,7 +12,6 @@ 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;
|
||||
@@ -84,11 +83,12 @@ public class CQuery<T> implements DbReadContext, CancelableQuery {
|
||||
/**
|
||||
* Flag set when 'master' bean changed.
|
||||
*/
|
||||
private boolean loadedBeanChanged;
|
||||
private boolean loadedBeanChanged;
|
||||
|
||||
/**
|
||||
* The 'master' bean just loaded.
|
||||
*/
|
||||
private Object loadedBean;
|
||||
private EntityBean loadedBean;
|
||||
|
||||
private final BeanPropertyAssocMany<?> lazyLoadManyProperty;
|
||||
|
||||
@@ -99,12 +99,12 @@ public class CQuery<T> implements DbReadContext, CancelableQuery {
|
||||
/**
|
||||
* Holds the previous loaded bean.
|
||||
*/
|
||||
private Object prevLoadedBean;
|
||||
private EntityBean prevLoadedBean;
|
||||
|
||||
/**
|
||||
* The detail bean just loaded.
|
||||
*/
|
||||
private Object loadedManyBean;
|
||||
private EntityBean loadedManyBean;
|
||||
|
||||
/**
|
||||
* The previous 'detail' collection remembered so that for manyToMany we can
|
||||
@@ -213,6 +213,7 @@ public class CQuery<T> implements DbReadContext, CancelableQuery {
|
||||
|
||||
private final CQueryPlan queryPlan;
|
||||
|
||||
|
||||
private final Mode queryMode;
|
||||
|
||||
private final boolean autoFetchProfiling;
|
||||
@@ -223,6 +224,7 @@ public class CQuery<T> implements DbReadContext, CancelableQuery {
|
||||
|
||||
private final WeakReference<NodeUsageListener> autoFetchManagerRef;
|
||||
|
||||
|
||||
private final Boolean readOnly;
|
||||
|
||||
private final SpiExpressionList<?> filterMany;
|
||||
@@ -230,7 +232,6 @@ public class CQuery<T> implements DbReadContext, CancelableQuery {
|
||||
private long startNano;
|
||||
|
||||
private long executionTimeMicros;
|
||||
|
||||
/**
|
||||
* Create the Sql select based on the request.
|
||||
*/
|
||||
@@ -445,7 +446,7 @@ public class CQuery<T> implements DbReadContext, CancelableQuery {
|
||||
return persistenceContext;
|
||||
}
|
||||
|
||||
public void setLoadedBean(Object bean, Object id, Object lazyLoadParentId) {
|
||||
public void setLoadedBean(EntityBean bean, Object id, Object lazyLoadParentId) {
|
||||
if (id != null && id.equals(loadedBeanId)) {
|
||||
// master/detail loading with master bean
|
||||
// unchanged. NB Using id to avoid any issue
|
||||
@@ -475,15 +476,14 @@ public class CQuery<T> implements DbReadContext, CancelableQuery {
|
||||
}
|
||||
}
|
||||
|
||||
public void setLoadedManyBean(Object manyValue) {
|
||||
public void setLoadedManyBean(EntityBean manyValue) {
|
||||
this.loadedManyBean = manyValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the last read bean.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public T getLoadedBean() {
|
||||
public EntityBean getLoadedBean() {
|
||||
if (manyIncluded) {
|
||||
if (prevDetailCollection instanceof BeanCollection<?>) {
|
||||
((BeanCollection<?>) prevDetailCollection).setModifyListening(manyProperty
|
||||
@@ -496,9 +496,9 @@ public class CQuery<T> implements DbReadContext, CancelableQuery {
|
||||
}
|
||||
|
||||
if (prevLoadedBean != null) {
|
||||
return (T) prevLoadedBean;
|
||||
return prevLoadedBean;
|
||||
} else {
|
||||
return (T) loadedBean;
|
||||
return loadedBean;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -684,10 +684,11 @@ public class CQuery<T> implements DbReadContext, CancelableQuery {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void readTheRows(boolean inForeground) throws SQLException {
|
||||
while (hasNextBean(inForeground)) {
|
||||
if (queryListener != null) {
|
||||
queryListener.process(getLoadedBean());
|
||||
queryListener.process((T)getLoadedBean());
|
||||
|
||||
} else {
|
||||
// add to the list/set/map
|
||||
@@ -697,7 +698,7 @@ public class CQuery<T> implements DbReadContext, CancelableQuery {
|
||||
}
|
||||
|
||||
protected boolean hasNextBean(boolean inForeground) throws SQLException {
|
||||
|
||||
|
||||
if (!readBeanInternal(inForeground)) {
|
||||
return false;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user