use of org.eclipse.persistence.testing.models.employee.domain.Employee in project eclipselink by eclipse-ee4j.
the class InsertTest method test.
@Override
public void test() {
Employee employee = new Employee();
java.math.BigDecimal id = new java.math.BigDecimal(7777);
java.util.Vector primaryKeys = new java.util.Vector();
employee.setId(id);
employee.setFirstName("Joe");
employee.setLastName("Blow");
primaryKeys.addElement(id);
cache.put(primaryKeys, employee, null, 0);
this.employee = employee;
}
use of org.eclipse.persistence.testing.models.employee.domain.Employee in project eclipselink by eclipse-ee4j.
the class TriggerValueHoldersSelfReferencingOneToOneTest method test.
/**
* Test case.
* Verify that {@code ConcurrentModificationException} is not thrown from {@code IdentityMapManager}
* during 2nd queries execution when objects are already in the cache.
*/
@Override
public void test() {
// We query for both Employees here because it is impossible to tell which order
// keys will be returned from the identity map in
// This bug only occurs when the first key returned is non-conforming and
// a future key must be looked up
ExpressionBuilder emp = new ExpressionBuilder();
Expression queryExp = emp.get("manager").get("firstName").equal("Bob");
ReadObjectQuery query = new ReadObjectQuery(Employee.class, queryExp);
query.conformResultsInUnitOfWork();
query.getInMemoryQueryIndirectionPolicy().triggerIndirection();
Employee bob = (Employee) uow.executeQuery(query);
assertNotNull(bob);
assertEquals("Bob", bob.getManager().getFirstName());
emp = new ExpressionBuilder();
queryExp = emp.get("manager").get("firstName").equal("John");
query = new ReadObjectQuery(Employee.class, queryExp);
query.conformResultsInUnitOfWork();
query.getInMemoryQueryIndirectionPolicy().triggerIndirection();
Employee john = (Employee) uow.executeQuery(query);
assertNotNull(john);
assertEquals("John", john.getManager().getFirstName());
}
use of org.eclipse.persistence.testing.models.employee.domain.Employee in project eclipselink by eclipse-ee4j.
the class UnitOfWorkConformReadObjectWithCriteriaTest method test.
@Override
public void test() {
for (Employee sampleEmployee : this.employees) {
Employee sampleManager = (Employee) sampleEmployee.getManager();
// execute the conforming query
Vector args = new Vector();
args.add(sampleEmployee.getManager().getId());
args.add(sampleEmployee.getLastName());
Employee employeeResult = (Employee) uow.executeQuery(this.queryToExecute, args);
assertNotNull("Employee should not be null", employeeResult);
Employee managerResult = (Employee) employeeResult.getManager();
assertNotNull("Manager should not be null", managerResult);
assertEquals("The returned Employee should have the same id as the sample Employee", sampleEmployee.getId(), employeeResult.getId());
assertEquals("The manager of the returned Employee should have the same id as the manager of the sample Employee", sampleManager.getId(), managerResult.getId());
}
}
use of org.eclipse.persistence.testing.models.employee.domain.Employee in project eclipselink by eclipse-ee4j.
the class UnitOfWorkConformReadObjectWithCriteriaTest method setup.
@Override
public void setup() {
this.employees = getSession().readAllObjects(Employee.class, new ExpressionBuilder().get("manager").notNull());
for (Employee employee : employees) {
assertNotNull(employee);
assertNotNull(employee.getManager());
}
// Set up conforming query to execute
ExpressionBuilder builder = new ExpressionBuilder();
this.queryToExecute = new ReadObjectQuery(Employee.class, builder);
Expression expression = builder.get("lastName").equal(builder.getParameter("employeeLastName"));
expression = expression.and(builder.get("manager").get("id").equal(builder.getParameter("managerId")));
this.queryToExecute.setSelectionCriteria(expression);
this.queryToExecute.conformResultsInUnitOfWork();
this.queryToExecute.addArgument("managerId", BigDecimal.class);
this.queryToExecute.addArgument("employeeLastName", String.class);
// start the test with an empty cache
getSession().getIdentityMapAccessor().initializeAllIdentityMaps();
// use the same uow for conforming queries
this.uow = getSession().acquireUnitOfWork();
}
use of org.eclipse.persistence.testing.models.employee.domain.Employee 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();
}
Aggregations