use of org.eclipse.persistence.testing.models.employee.domain.Employee in project eclipselink by eclipse-ee4j.
the class SimpleConcatTestWithConstantsLiteralFirst method setup.
@Override
public void setup() {
Employee emp = (Employee) getSomeEmployees().firstElement();
String partOne;
String ejbqlString;
partOne = emp.getFirstName();
ExpressionBuilder builder = new ExpressionBuilder();
Expression whereClause = builder.literal("'Smith'").concat(builder.get("firstName")).like("Smith" + partOne);
ReadAllQuery raq = new ReadAllQuery();
raq.setReferenceClass(Employee.class);
raq.setSelectionCriteria(whereClause);
Vector employees = (Vector) getSession().executeQuery(raq);
ejbqlString = "SELECT OBJECT(emp) FROM Employee emp WHERE ";
ejbqlString = ejbqlString + "CONCAT(\"Smith\",emp.firstName) LIKE ";
ejbqlString = ejbqlString + "\"Smith" + partOne + "\"";
setEjbqlString(ejbqlString);
setOriginalOject(employees);
super.setup();
}
use of org.eclipse.persistence.testing.models.employee.domain.Employee in project eclipselink by eclipse-ee4j.
the class OracleNativeSeqInitTest method setup.
@Override
public void setup() {
if (!getSession().getPlatform().supportsSequenceObjects()) {
throw new TestWarningException("This test requires a platform that supports sequence objects");
}
ClassDescriptor descriptor = getSession().getDescriptor(Employee.class);
if (!descriptor.usesSequenceNumbers()) {
throw new TestWarningException("Employee doesn't use sequencing");
}
originalSequence = getSession().getPlatform().getSequence(descriptor.getSequenceNumberName());
usesNativeSequencingOriginal = (originalSequence instanceof NativeSequence || (originalSequence instanceof DefaultSequence && getSession().getPlatform().getDefaultSequence() instanceof NativeSequence)) && !originalSequence.shouldAcquireValueAfterInsert();
if (!usesNativeSequencingOriginal) {
NativeSequence newSequence = new NativeSequence(originalSequence.getName(), originalSequence.getPreallocationSize());
newSequence.onConnect(originalSequence.getDatasourcePlatform());
getAbstractSession().getPlatform().addSequence(newSequence);
sequence = newSequence;
} else {
sequence = originalSequence;
}
seqPreallocationSizeOriginal = originalSequence.getPreallocationSize();
lastSeqNumberOriginal = getSession().getNextSequenceNumberValue(Employee.class).intValue() - 1;
usesBatchWritingOriginal = getSession().getPlatform().usesBatchWriting();
shouldCacheAllStatementsOriginal = getSession().getPlatform().shouldCacheAllStatements();
getDatabaseSession().getSequencingControl().initializePreallocated();
sequenceDefinition = new SequenceObjectDefinition(sequence);
sequenceDefinition.setQualifier(getSession().getLogin().getTableQualifier());
if (shouldUseSchemaManager) {
schemaManager = new SchemaManager(getDatabaseSession());
// make sure that upcoming DROP and CREATE haven't been cached
// and therefore for sure will go through
getSession().getPlatform().setShouldCacheAllStatements(false);
// This is the worst case scenario settings - SchemaManager should handle it.
getSession().getPlatform().setUsesBatchWriting(true);
getSession().getPlatform().setShouldCacheAllStatements(true);
} else {
getSession().getPlatform().setUsesBatchWriting(false);
getSession().getPlatform().setShouldCacheAllStatements(false);
}
// all three modes start with dropping an existing sequence (if any)
try {
drop();
} catch (DatabaseException exception) {
// Ignore already deleted
}
if (mode == DROP_CREATE) {
// sequence doesn't exist.
// create sequence with seqPreallocationSize.
// note that both increment and starting value are set to
// sequenceDefinition.getIncrement()
sequence.setInitialValue(1);
sequence.setPreallocationSize(seqPreallocationSize);
create();
// next available sequence number.
idExpected = 1;
} else if (mode == CREATE_CREATE) {
// sequence doesn't exist,
// create sequence with seqPreallocationSizeOld
// note that both increment and starting value are set to
// sequenceDefinition.getIncrement()
sequence.setInitialValue(1);
sequence.setPreallocationSize(seqPreallocationSizeOld);
create();
// now sequence exists,
// create sequence with seqPreallocationSize
// Note that createOnDatabase will call alterOnDatabase
sequence.setInitialValue(1);
sequence.setPreallocationSize(seqPreallocationSize);
create();
// next available sequence number.
// note that the second createOnDatabase selects NEXTVAL during existance check,
// because it is the first call to NEXTVAL, the starting sequence value is returned,
// and this value was set to seqPreallocationSizeOld by the first createOnDatabase
idExpected = 1 + seqPreallocationSizeOld;
} else if (mode == NEXTVAL_ALTER) {
// sequence doesn't exist,
// create sequence with seqPreallocationSizeOld
// note that both increment and starting value are set to
// sequenceDefinition.getIncrement()
sequence.setInitialValue(1);
sequence.setPreallocationSize(seqPreallocationSizeOld);
create();
// now sequence exists,
// select NEXTVAL
// because it is the first call to NEXTVAL, the starting sequence value is returned,
// and this value was set to seqPreallocationSizeOld by the first createOnDatabase
sequenceDefinition.checkIfExist((AbstractSession) getSession());
// alter increment of sequence with seqPreallocationSize.
sequence.setInitialValue(1);
sequence.setPreallocationSize(seqPreallocationSize);
alter();
// next available sequence number.
// because there was just one call to NEXTVAL, the starting sequence value is returned,
// and this value was set to seqPreallocationSizeOld by createOnDatabase
idExpected = 1 + seqPreallocationSizeOld;
} else if (mode == CREATE_ALTER) {
// sequence doesn't exist,
// create sequence with seqPreallocationSizeOld
// note that both increment and starting value are set to
// sequenceDefinition.getIncrement()
sequence.setInitialValue(1);
sequence.setPreallocationSize(seqPreallocationSizeOld);
create();
// alter increment of sequence with seqPreallocationSize.
sequence.setInitialValue(1);
sequence.setPreallocationSize(seqPreallocationSize);
alter();
// next available sequence number.
idExpected = 1;
}
getSession().getPlatform().getSequence(descriptor.getSequenceNumberName()).setPreallocationSize(seqPreallocationSize);
}
use of org.eclipse.persistence.testing.models.employee.domain.Employee in project eclipselink by eclipse-ee4j.
the class LowerCaseForCaseInsensitiveTest method testEqualsIgnoreCase.
public void testEqualsIgnoreCase(boolean checkCacheOnly) {
String value = "s" + uUmlaut + sharpS + "IG";
ReadAllQuery query = new ReadAllQuery(Employee.class);
if (checkCacheOnly) {
query.checkCacheOnly();
}
query.setSelectionCriteria(new ExpressionBuilder().get("lastName").equalsIgnoreCase(value));
Vector<Employee> results = (Vector<Employee>) getSession().executeQuery(query);
assertEquals("One result expected (checkCacheOnly=" + checkCacheOnly + ")", 1, results.size());
assertTrue("Persisted employee expected in results (checkCacheOnly=" + checkCacheOnly + ")", results.contains(employee));
}
use of org.eclipse.persistence.testing.models.employee.domain.Employee in project eclipselink by eclipse-ee4j.
the class QueryTimeoutBatchDescriptorQueryManagerTest method registerObjects.
/**
* Iterate and register a number of objects in the unitOfWork
*/
@Override
protected List<Employee> registerObjects(UnitOfWork uow) {
List<Employee> objectListForEditing = new ArrayList<Employee>();
Address address = null;
Employee employee = null;
for (int i = 0; i < getNumberOfInserts(); i++) {
address = new Address();
address.setCity(new StringBuffer("city").append(i).toString());
address.setProvince(new StringBuffer("province").append(i).toString());
employee = new Employee();
employee.setFirstName(new StringBuffer("first").append(i).toString());
employee.setLastName(new StringBuffer("last").append(i).toString());
// employee.setId(new java.math.BigDecimal(i));
employee.setAddress(address);
uow.registerObject(employee);
// Use the return clone for editing
objectListForEditing.add(employee);
// Test framework callback
// Set the timeout at the descriptor level for each object
setDescriptorLevelQueryTimeout(uow.getDescriptor(employee).getDescriptorQueryManager());
setDescriptorLevelQueryTimeout(uow.getDescriptor(address).getDescriptorQueryManager());
// Test framework callback
// Set the timeout on each query object (already defined)
setQueryLevelQueryTimeout(uow, employee);
setQueryLevelQueryTimeout(uow, address);
// Add custom insertQuery
InsertObjectQuery query = new InsertObjectQuery();
// queryCount++;
// insert into employee (emp_id, version) SELECT 40003, SUM(e.address_id) as version from address e, address b, address b, address c, address c;
StringBuffer sBuffer = new StringBuffer(getQuerySQLPrefix());
sBuffer.append(getCurrentIDSequence() + i);
// sBuffer.append(i);
sBuffer.append(getQuerySQLPostfix());
query.setSQLString(sBuffer.toString());
// Override parent
query.setQueryTimeout(getChildQueryTimeout());
// We don't set the f_name parameter so Ignore: WARNING: Missing Query parameter for named argument: 1 null will be substituted.
uow.getDescriptor(employee).getDescriptorQueryManager().setInsertQuery(query);
}
return objectListForEditing;
}
use of org.eclipse.persistence.testing.models.employee.domain.Employee in project eclipselink by eclipse-ee4j.
the class LowerCaseForCaseInsensitiveTest method setup.
@Override
public void setup() {
// set the Expression default upper case value to lower case
Expression.shouldUseUpperCaseForIgnoreCase = false;
UnitOfWork uow = getSession().acquireUnitOfWork();
employee = new Employee();
Employee employeeClone = (Employee) uow.registerObject(employee);
employeeClone.setFirstName("Heinz");
employeeClone.setLastName("S\u00fc\u00dfig");
employeeClone.setMale();
uow.commit();
}
Aggregations