Search in sources :

Example 1 with Address

use of org.eclipse.persistence.testing.models.employee.domain.Address in project eclipselink by eclipse-ee4j.

the class NestedUnitOfWorkMultipleCommitTest method changeNestedUnitOfWorkAgain.

protected void changeNestedUnitOfWorkAgain() {
    // Many to many
    nestedUnitOfWorkWorkingCopy.setProjects(new Vector());
    // Direct collection
    nestedUnitOfWorkWorkingCopy.addResponsibility("eat not buy donuts");
    // One to one private/public
    nestedUnitOfWorkWorkingCopy.setAddress(new Address());
    nestedUnitOfWorkWorkingCopy.setManager(null);
}
Also used : Address(org.eclipse.persistence.testing.models.employee.domain.Address) Vector(java.util.Vector)

Example 2 with Address

use of org.eclipse.persistence.testing.models.employee.domain.Address in project eclipselink by eclipse-ee4j.

the class NestedUnitOfWorkReadOnlyClassTest method test.

@Override
public void test() {
    getSession().getIdentityMapAccessor().initializeAllIdentityMaps();
    // start root transaction
    UnitOfWork rootUOW = getSession().acquireUnitOfWork();
    Address addressRO = (Address) getSession().readObject(Address.class, new ExpressionBuilder().get("postalCode").equal(postalCode));
    if (addressRO == null) {
        throw new TestErrorException("Unable to find address.");
    }
    // start nested transaction
    UnitOfWork nestedUOW = rootUOW.acquireUnitOfWork();
    nestedUOW.addReadOnlyClass(Address.class);
    Employee emp = (Employee) nestedUOW.registerObject(new Employee());
    nestedUOW.assignSequenceNumber(emp);
    emp.setFirstName("John");
    emp.setAddress(addressRO);
    nestedUOW.commit();
    rootUOW.commit();
    originalEmployee = emp;
}
Also used : UnitOfWork(org.eclipse.persistence.sessions.UnitOfWork) Employee(org.eclipse.persistence.testing.models.employee.domain.Employee) Address(org.eclipse.persistence.testing.models.employee.domain.Address) TestErrorException(org.eclipse.persistence.testing.framework.TestErrorException) ExpressionBuilder(org.eclipse.persistence.expressions.ExpressionBuilder)

Example 3 with Address

use of org.eclipse.persistence.testing.models.employee.domain.Address in project eclipselink by eclipse-ee4j.

the class NestedUnitOfWorkTest method changeUnitOfWorkWorkingCopy.

protected void changeUnitOfWorkWorkingCopy() {
    Employee employee = (Employee) this.unitOfWorkWorkingCopy;
    // Transformation
    employee.setNormalHours(new java.sql.Time[2]);
    employee.setStartTime(Helper.timeFromHourMinuteSecond(1, 1, 1));
    employee.setEndTime(Helper.timeFromHourMinuteSecond(1, 1, 1));
    // Aggregate
    employee.setPeriod(new EmploymentPeriod(Helper.dateFromYearMonthDate(1901, 1, 1), Helper.dateFromYearMonthDate(1902, 2, 2)));
    // One to many private
    employee.setPhoneNumbers(new Vector());
    employee.addPhoneNumber(new PhoneNumber("home", "613", "2263374"));
    employee.addPhoneNumber(new PhoneNumber("office", "416", "8224599"));
    // Many to many
    employee.setProjects(new Vector());
    employee.addProject((Project) this.unitOfWork.readObject(SmallProject.class));
    employee.addProject((Project) this.unitOfWork.readObject(LargeProject.class));
    // Direct collection
    employee.setResponsibilitiesList(new Vector());
    employee.addResponsibility("make coffee");
    employee.addResponsibility("buy donuts");
    // One to one private/public
    employee.setAddress(new Address());
    // make sure that the employee is not his own manager
    employee.setManager((Employee) this.unitOfWork.readObject(Employee.class, (new ExpressionBuilder()).get("id").notEqual(employee.getId())));
}
Also used : EmploymentPeriod(org.eclipse.persistence.testing.models.employee.domain.EmploymentPeriod) Employee(org.eclipse.persistence.testing.models.employee.domain.Employee) Address(org.eclipse.persistence.testing.models.employee.domain.Address) PhoneNumber(org.eclipse.persistence.testing.models.employee.domain.PhoneNumber) ExpressionBuilder(org.eclipse.persistence.expressions.ExpressionBuilder) Vector(java.util.Vector)

Example 4 with Address

use of org.eclipse.persistence.testing.models.employee.domain.Address in project eclipselink by eclipse-ee4j.

the class NLSEmployeePopulator method addressExample2.

public Address addressExample2() {
    Address address = new Address();
    address.setCity("\u305d\u30c8\u30c8\u30a2\u30cc\u30a2");
    address.setPostalCode("K5J2B5");
    address.setProvince("\u305d\u305b\u3068");
    address.setStreet("12 \u3059\u30aa\u30c4\u30b1\u30cb\u30a2\u30b7 \u3064\u30a8., \u30c6\u30ca\u30b1\u30c8\u30aa 5");
    address.setCountry("\u3046\u30a2\u30bb\u30a2\u30a8\u30a2");
    return address;
}
Also used : Address(org.eclipse.persistence.testing.models.employee.domain.Address)

Example 5 with Address

use of org.eclipse.persistence.testing.models.employee.domain.Address in project eclipselink by eclipse-ee4j.

the class NLSEmployeePopulator method addressExample5.

public Address addressExample5() {
    Address address = new Address();
    address.setCity("\u306b\u30a2\u30bb\u30a6\u30db\u30ca\u30cb\u30aa\u30c4");
    address.setPostalCode("N5J2N5");
    address.setProvince("\u3044\u3046");
    address.setStreet("1111 \u3059\u30db\u30ca\u30bb\u30c8\u30a2\u30b1\u30bb \u3044\u30b7\u30cb\u30a8. \u304b\u30b7\u30db\u30db\u30c4 53, \u30c6\u30ca\u30b1\u30c8\u30aa 6");
    address.setCountry("\u3046\u30a2\u30bb\u30a2\u30a8\u30a2");
    return address;
}
Also used : Address(org.eclipse.persistence.testing.models.employee.domain.Address)

Aggregations

Address (org.eclipse.persistence.testing.models.employee.domain.Address)48 Employee (org.eclipse.persistence.testing.models.employee.domain.Employee)21 Vector (java.util.Vector)10 UnitOfWork (org.eclipse.persistence.sessions.UnitOfWork)10 TestErrorException (org.eclipse.persistence.testing.framework.TestErrorException)7 ExpressionBuilder (org.eclipse.persistence.expressions.ExpressionBuilder)5 SmallProject (org.eclipse.persistence.testing.models.employee.domain.SmallProject)5 UnitOfWorkImpl (org.eclipse.persistence.internal.sessions.UnitOfWorkImpl)4 Expression (org.eclipse.persistence.expressions.Expression)3 Session (org.eclipse.persistence.sessions.Session)3 TestWarningException (org.eclipse.persistence.testing.framework.TestWarningException)3 PhoneNumber (org.eclipse.persistence.testing.models.employee.domain.PhoneNumber)3 ReadObjectQuery (org.eclipse.persistence.queries.ReadObjectQuery)2 EmploymentPeriod (org.eclipse.persistence.testing.models.employee.domain.EmploymentPeriod)2 Project (org.eclipse.persistence.testing.models.employee.domain.Project)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1 ObjectInputStream (java.io.ObjectInputStream)1 ObjectOutputStream (java.io.ObjectOutputStream)1