Skip Headers

# Proxy Indirection Restrictions

Previous

Next

Proxy objects in Java are only able to intercept messages sent. If a primitive operation such as `==`, `instanceof`, or `getClass` is used on a proxy, it will not be intercepted. This limitation can require the application to be somewhat aware of the usage of proxy objects.

You cannot register the target of a proxy indirection implementation with a unit of work. Instead, first register the source object with the unit of work. This lets you retrieve a target object clone with a call to a getter on the source object clone.

For example:

    UnitOfWork uow = session.acquireUnitOfWork();
    Employee emp = (Employee)session.readObject(Employee.class);

    // Register the source object
    Employee empClone = (Employee)uow.registerObject(emp);

    // All of source object's relationships are cloned when source object is cloned
    Address addressClone = empClone.getAddress();
    addressClone.setCity("Toronto");

For more information about clones and the unit of work, see Understanding TopLink Transactions.