use of org.eclipse.persistence.queries.ScrollableCursor in project eclipselink by eclipse-ee4j.
the class ScrollableCursorJoinedAttributeTest method test.
@Override
public void test() {
if (getSession().getPlatform().isHANA() || getSession().getPlatform().isSQLServer()) {
throw new TestWarningException("ScrollableCursor is not supported on this platform");
}
getSession().getIdentityMapAccessor().initializeAllIdentityMaps();
cursoredResults = new Vector();
ReadAllQuery cursoredQuery = new ReadAllQuery(Employee.class);
cursoredQuery.useScrollableCursor();
cursoredQuery.addJoinedAttribute(cursoredQuery.getExpressionBuilder().anyOfAllowingNone("phoneNumbers"));
cursoredQuery.addOrdering(cursoredQuery.getExpressionBuilder().get("id"));
try {
ScrollableCursor cursor = (ScrollableCursor) getSession().executeQuery(cursoredQuery);
while (cursor.hasNext()) {
Object result = cursor.next();
cursoredResults.add(result);
}
cursor.close();
} catch (Exception e) {
caughtException = e;
}
}
use of org.eclipse.persistence.queries.ScrollableCursor in project eclipselink by eclipse-ee4j.
the class ScrollableCursorJoiningVerificationTest method test.
@Override
public void test() {
if (getSession().getPlatform().isHANA() || getSession().getPlatform().isSQLServer()) {
throw new TestWarningException("ScrollableCursor is not supported on this platform");
}
// non-cursored results
getSession().getIdentityMapAccessor().initializeAllIdentityMaps();
ReadAllQuery nonCursoredQuery = new ReadAllQuery(Employee.class);
nonCursoredQuery.dontCheckCache();
nonCursoredQuery.addJoinedAttribute(nonCursoredQuery.getExpressionBuilder().anyOfAllowingNone("phoneNumbers"));
nonCursoredQuery.addOrdering(nonCursoredQuery.getExpressionBuilder().get("id"));
nonCursoredResults = (List) getSession().executeQuery(nonCursoredQuery);
// forward cursored results
getSession().getIdentityMapAccessor().initializeAllIdentityMaps();
forwardCursoredResults = new ArrayList<Employee>();
ReadAllQuery cursoredQuery = new ReadAllQuery(Employee.class);
nonCursoredQuery.dontCheckCache();
cursoredQuery.useScrollableCursor();
cursoredQuery.addJoinedAttribute(cursoredQuery.getExpressionBuilder().anyOfAllowingNone("phoneNumbers"));
cursoredQuery.addOrdering(cursoredQuery.getExpressionBuilder().get("id"));
ScrollableCursor cursor = (ScrollableCursor) getSession().executeQuery(cursoredQuery);
while (cursor.hasNext()) {
Employee result = (Employee) cursor.next();
forwardCursoredResults.add(result);
}
// reverse cursored results - use the same cursor
reverseCursoredResults = new ArrayList();
while (cursor.hasPrevious()) {
Employee result = (Employee) cursor.previous();
reverseCursoredResults.add(result);
}
cursor.close();
}
use of org.eclipse.persistence.queries.ScrollableCursor in project eclipselink by eclipse-ee4j.
the class RemoteSessionController method scrollableCursorNextObject.
/**
* Retrieve next object from the scrollable cursor
*/
public Transporter scrollableCursorNextObject(Transporter remoteScrollableCursorOid) {
Transporter transporter = new Transporter();
try {
ScrollableCursor stream = (ScrollableCursor) getRemoteCursors().get(remoteScrollableCursorOid.getObject());
if (stream != null) {
Object objectNext = null;
// For bug 2797683 read beyond end of stream exception should not be thrown here: called first by RemoteScrollableCursor.hasNext().
if (stream.hasNext()) {
objectNext = stream.next();
}
if (objectNext == null) {
// 2612538 - the default size of Map (32) is appropriate
transporter.setObjectDescriptors(new IdentityHashMap());
} else {
if (stream.getQuery().isReadAllQuery() && (!stream.getQuery().isReportQuery())) {
transporter.setObjectDescriptors(replaceValueHoldersIn(objectNext));
}
}
transporter.setObject(objectNext);
}
} catch (RuntimeException exception) {
transporter.setException(exception);
}
return transporter;
}
use of org.eclipse.persistence.queries.ScrollableCursor in project eclipselink by eclipse-ee4j.
the class RemoteSessionController method scrollableCursorPreviousObject.
/**
* Retrieve previous object from the scrollable cursor
*/
public Transporter scrollableCursorPreviousObject(Transporter remoteScrollableCursorOid) {
Transporter transporter = new Transporter();
try {
ScrollableCursor stream = (ScrollableCursor) getRemoteCursors().get(remoteScrollableCursorOid.getObject());
if (stream != null) {
Object objectPrevious = null;
// For bug 2797683 read beyond end of stream exception should not be thrown here: called first by RemoteScrollableCursor.hasNext().
if (stream.hasPrevious()) {
objectPrevious = stream.previous();
}
if (objectPrevious == null) {
// 2612538 - the default size of Map (32) is appropriate
transporter.setObjectDescriptors(new IdentityHashMap());
} else {
if (stream.getQuery().isReadAllQuery() && (!stream.getQuery().isReportQuery())) {
transporter.setObjectDescriptors(replaceValueHoldersIn(objectPrevious));
}
}
transporter.setObject(objectPrevious);
}
} catch (RuntimeException exception) {
transporter.setException(exception);
}
return transporter;
}
use of org.eclipse.persistence.queries.ScrollableCursor in project eclipselink by eclipse-ee4j.
the class RemoteSessionController method closeScrollableCursor.
/**
* Used for closing scrolable cursor across RMI.
*/
public Transporter closeScrollableCursor(ObjID id) {
Transporter transporter = new Transporter();
try {
ScrollableCursor stream = (ScrollableCursor) getRemoteCursors().get(id);
if (stream != null) {
stream.close();
}
getRemoteCursors().remove(id);
} catch (RuntimeException exception) {
transporter.setException(exception);
}
return transporter;
}
Aggregations