You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by fm...@apache.org on 2014/07/18 18:07:53 UTC

[14/15] git commit: [OLINGO-366, OLINGO-367, OLINGO-370] chahnged entity, entity collection and complex creation methods (still missing complex collection creator). Provided delayed HTTP request for navigation property. Provided select query option support

[OLINGO-366,OLINGO-367,OLINGO-370] chahnged entity, entity collection and complex creation methods (still missing complex collection creator). Provided delayed HTTP request for navigation property. Provided select query option support on entity set (still missing query options support for entity collections)


Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/989babb1
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/989babb1
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/989babb1

Branch: refs/heads/master
Commit: 989babb1dc83cad5503bad8f784b56e436d59246
Parents: b9db730
Author: fmartelli <fa...@gmail.com>
Authored: Fri Jul 18 17:51:48 2014 +0200
Committer: fmartelli <fa...@gmail.com>
Committed: Fri Jul 18 17:51:48 2014 +0200

----------------------------------------------------------------------
 .../org/apache/olingo/ext/proxy/Service.java    |  38 +++++-
 .../ext/proxy/api/AbstractEntityCollection.java |  25 ----
 .../olingo/ext/proxy/api/AbstractEntitySet.java |   6 +-
 .../olingo/ext/proxy/api/AbstractSingleton.java |   2 +-
 .../olingo/ext/proxy/api/CollectionQuery.java   |   2 +-
 .../olingo/ext/proxy/api/ComplexType.java       |  22 +++
 .../olingo/ext/proxy/api/EntityCollection.java  |  25 ++++
 .../ext/proxy/api/EntityCollectionQuery.java    |   2 +-
 .../olingo/ext/proxy/api/EntitySetQuery.java    |   4 +-
 .../apache/olingo/ext/proxy/api/EntityType.java |  22 +++
 .../org/apache/olingo/ext/proxy/api/Search.java |   2 +-
 .../ext/proxy/api/annotations/EntitySet.java    |   2 +
 .../ext/proxy/api/annotations/Singleton.java    |   2 +
 ...stractEntityCollectionInvocationHandler.java |  19 +--
 .../commons/AbstractInvocationHandler.java      |  27 ++--
 .../commons/AbstractPersistenceManager.java     | 118 +++++++++-------
 .../AbstractStructuredInvocationHandler.java    | 106 +++++++--------
 .../commons/AnnotatableInvocationHandler.java   |   7 +-
 .../commons/AnnotatationsInvocationHandler.java |   9 +-
 .../ComplexFactoryInvocationHandler.java        |  17 +--
 .../proxy/commons/ComplexInvocationHandler.java |  26 +++-
 .../EntityCollectionInvocationHandler.java      |  27 ++--
 .../EntityContainerInvocationHandler.java       |  18 ++-
 .../proxy/commons/EntityInvocationHandler.java  |  96 ++++++++++---
 .../commons/EntitySetInvocationHandler.java     | 136 +++++++++----------
 .../ext/proxy/commons/EntitySetIterator.java    |  12 +-
 .../NonTransactionalPersistenceManagerImpl.java |  35 ++++-
 .../commons/OperationInvocationHandler.java     |  11 +-
 .../olingo/ext/proxy/commons/SearchImpl.java    |   7 +-
 .../commons/SingletonInvocationHandler.java     |  19 ++-
 .../TransactionalPersistenceManagerImpl.java    |   4 +-
 .../olingo/ext/proxy/context/EntityContext.java |   8 +-
 .../olingo/ext/proxy/context/EntityUUID.java    |  17 +--
 .../olingo/ext/proxy/utils/CoreUtils.java       |  26 ++++
 .../olingo/ext/pojogen/AbstractPOJOGenMojo.java |  24 +---
 .../src/main/resources/complexCreator.vm        |  32 -----
 .../src/main/resources/complexType.vm           |   3 +-
 .../src/main/resources/container.vm             |  19 +--
 .../src/main/resources/entityCollection.vm      |   6 +-
 .../src/main/resources/entityCreator.vm         |  37 -----
 .../src/main/resources/entitySet.vm             |  12 +-
 .../src/main/resources/entityType.vm            |  25 +---
 .../src/main/resources/entityTypeKey.vm         |   3 +-
 .../src/main/resources/enumType.vm              |   2 +
 .../src/main/resources/singleton.vm             |   3 +-
 .../src/main/resources/term.vm                  |   3 +-
 .../src/main/resources/v30/complexType.vm       |  14 +-
 .../src/main/resources/v40/complexType.vm       |  14 +-
 .../src/main/resources/v40/singleton.vm         |   2 +-
 .../olingo/fit/proxy/v3/AbstractTestITCase.java |  59 ++++----
 .../proxy/v3/ActionOverloadingTestITCase.java   |  17 +--
 .../olingo/fit/proxy/v3/AsyncTestITCase.java    |  17 +--
 .../olingo/fit/proxy/v3/ContextTestITCase.java  | 116 ++++++++--------
 .../fit/proxy/v3/EntityCreateTestITCase.java    |  42 +++---
 .../fit/proxy/v3/EntityRetrieveTestITCase.java  |  80 +++++------
 .../fit/proxy/v3/EntitySetTestITCase.java       |  17 +--
 .../fit/proxy/v3/EntityUpdateTestITCase.java    |  41 +++---
 .../olingo/fit/proxy/v3/FilterTestITCase.java   |  17 +--
 .../olingo/fit/proxy/v3/InvokeTestITCase.java   |  48 ++++---
 .../fit/proxy/v3/MediaEntityTestITCase.java     |  22 +--
 .../olingo/fit/proxy/v3/OpenTypeTestITCase.java |  41 +++---
 .../fit/proxy/v3/PrimitiveKeysTestITCase.java   |  17 +--
 .../olingo/fit/proxy/v3/PropertyTestITCase.java |  17 +--
 .../AllGeoCollectionTypesSet.java               |   9 +-
 .../astoriadefaultservice/AllGeoTypesSet.java   |   7 +-
 .../services/astoriadefaultservice/Car.java     |   7 +-
 .../astoriadefaultservice/Computer.java         |   7 +-
 .../astoriadefaultservice/ComputerDetail.java   |   7 +-
 .../astoriadefaultservice/Customer.java         |   7 +-
 .../astoriadefaultservice/CustomerInfo.java     |   7 +-
 .../astoriadefaultservice/DefaultContainer.java |  41 +-----
 .../services/astoriadefaultservice/Driver.java  |   7 +-
 .../astoriadefaultservice/LastLogin.java        |   7 +-
 .../services/astoriadefaultservice/License.java |   7 +-
 .../services/astoriadefaultservice/Login.java   |   7 +-
 .../astoriadefaultservice/MappedEntityType.java |   7 +-
 .../services/astoriadefaultservice/Message.java |  11 +-
 .../MessageAttachment.java                      |   7 +-
 .../services/astoriadefaultservice/Order.java   |   7 +-
 .../astoriadefaultservice/OrderLine.java        |  15 +-
 .../astoriadefaultservice/PageView.java         |   9 +-
 .../services/astoriadefaultservice/Person.java  |  13 +-
 .../astoriadefaultservice/PersonMetadata.java   |   7 +-
 .../services/astoriadefaultservice/Product.java |   9 +-
 .../astoriadefaultservice/ProductDetail.java    |   7 +-
 .../astoriadefaultservice/ProductPhoto.java     |  11 +-
 .../astoriadefaultservice/ProductReview.java    |  11 +-
 .../astoriadefaultservice/RSAToken.java         |   7 +-
 .../astoriadefaultservice/types/Aliases.java    |  10 +-
 .../types/AllSpatialCollectionTypes.java        |  14 +-
 .../AllSpatialCollectionTypesCollection.java    |   6 +-
 .../types/AllSpatialCollectionTypes_Simple.java |  14 +-
 ...SpatialCollectionTypes_SimpleCollection.java |   6 +-
 .../types/AllSpatialTypes.java                  |  14 +-
 .../types/AllSpatialTypesCollection.java        |   6 +-
 .../astoriadefaultservice/types/AuditInfo.java  |  14 +-
 .../types/BackOrderLine.java                    |  14 +-
 .../types/BackOrderLine2.java                   |  14 +-
 .../types/BackOrderLine2Collection.java         |   6 +-
 .../types/BackOrderLineCollection.java          |   6 +-
 .../astoriadefaultservice/types/Car.java        |  14 +-
 .../types/CarCollection.java                    |   6 +-
 .../types/ComplexToCategory.java                |  10 +-
 .../astoriadefaultservice/types/Computer.java   |  14 +-
 .../types/ComputerCollection.java               |   6 +-
 .../types/ComputerDetail.java                   |  18 +--
 .../types/ComputerDetailCollection.java         |   6 +-
 .../types/ConcurrencyInfo.java                  |  10 +-
 .../types/ContactDetails.java                   |  26 +---
 .../astoriadefaultservice/types/Contractor.java |  16 +--
 .../types/ContractorCollection.java             |   6 +-
 .../astoriadefaultservice/types/Customer.java   |  26 +---
 .../types/CustomerCollection.java               |   6 +-
 .../types/CustomerInfo.java                     |  14 +-
 .../types/CustomerInfoCollection.java           |   6 +-
 .../astoriadefaultservice/types/Dimensions.java |  10 +-
 .../types/DiscontinuedProduct.java              |  30 +---
 .../types/DiscontinuedProductCollection.java    |   6 +-
 .../astoriadefaultservice/types/Driver.java     |  14 +-
 .../types/DriverCollection.java                 |   6 +-
 .../astoriadefaultservice/types/Employee.java   |  16 +--
 .../types/EmployeeCollection.java               |   6 +-
 .../astoriadefaultservice/types/LastLogin.java  |  14 +-
 .../types/LastLoginCollection.java              |   6 +-
 .../astoriadefaultservice/types/License.java    |  14 +-
 .../types/LicenseCollection.java                |   6 +-
 .../astoriadefaultservice/types/Login.java      |  14 +-
 .../types/LoginCollection.java                  |   6 +-
 .../types/MappedEntityType.java                 |  26 +---
 .../types/MappedEntityTypeCollection.java       |   6 +-
 .../astoriadefaultservice/types/Message.java    |  14 +-
 .../types/MessageAttachment.java                |  14 +-
 .../types/MessageAttachmentCollection.java      |   6 +-
 .../types/MessageCollection.java                |   6 +-
 .../astoriadefaultservice/types/MessageKey.java |   4 +-
 .../astoriadefaultservice/types/Order.java      |  18 +--
 .../types/OrderCollection.java                  |   6 +-
 .../astoriadefaultservice/types/OrderLine.java  |  16 +--
 .../types/OrderLineCollection.java              |   6 +-
 .../types/OrderLineKey.java                     |   4 +-
 .../astoriadefaultservice/types/PageView.java   |  14 +-
 .../types/PageViewCollection.java               |   6 +-
 .../astoriadefaultservice/types/Person.java     |  16 +--
 .../types/PersonCollection.java                 |   6 +-
 .../types/PersonMetadata.java                   |  14 +-
 .../types/PersonMetadataCollection.java         |   6 +-
 .../astoriadefaultservice/types/Phone.java      |  10 +-
 .../astoriadefaultservice/types/Product.java    |  28 +---
 .../types/ProductCollection.java                |   6 +-
 .../types/ProductDetail.java                    |  14 +-
 .../types/ProductDetailCollection.java          |   6 +-
 .../types/ProductPageView.java                  |  14 +-
 .../types/ProductPageViewCollection.java        |   6 +-
 .../types/ProductPhoto.java                     |  14 +-
 .../types/ProductPhotoCollection.java           |   6 +-
 .../types/ProductPhotoKey.java                  |   4 +-
 .../types/ProductReview.java                    |  14 +-
 .../types/ProductReviewCollection.java          |   6 +-
 .../types/ProductReviewKey.java                 |   4 +-
 .../astoriadefaultservice/types/RSAToken.java   |  14 +-
 .../types/RSATokenCollection.java               |   6 +-
 .../types/SpecialEmployee.java                  |  16 +--
 .../types/SpecialEmployeeCollection.java        |   6 +-
 .../opentypesservicev3/DefaultContainer.java    |  15 +-
 .../odata/services/opentypesservicev3/Row.java  |   9 +-
 .../services/opentypesservicev3/RowIndex.java   |   7 +-
 .../types/ContactDetails.java                   |  10 +-
 .../opentypesservicev3/types/IndexedRow.java    |  16 +--
 .../types/IndexedRowCollection.java             |   6 +-
 .../services/opentypesservicev3/types/Row.java  |  16 +--
 .../opentypesservicev3/types/RowCollection.java |   6 +-
 .../opentypesservicev3/types/RowIndex.java      |  16 +--
 .../types/RowIndexCollection.java               |   6 +-
 .../primitivekeysservice/EdmBinarySet.java      |   7 +-
 .../primitivekeysservice/EdmBooleanSet.java     |   7 +-
 .../primitivekeysservice/EdmByteSet.java        |   7 +-
 .../EdmDateTimeOffsetSet.java                   |   7 +-
 .../primitivekeysservice/EdmDateTimeSet.java    |   7 +-
 .../primitivekeysservice/EdmDecimalSet.java     |   7 +-
 .../primitivekeysservice/EdmDoubleSet.java      |   7 +-
 .../primitivekeysservice/EdmGuidSet.java        |   7 +-
 .../primitivekeysservice/EdmInt16Set.java       |   7 +-
 .../primitivekeysservice/EdmInt32Set.java       |   7 +-
 .../primitivekeysservice/EdmInt64Set.java       |   7 +-
 .../primitivekeysservice/EdmSingleSet.java      |   7 +-
 .../primitivekeysservice/EdmStringSet.java      |   7 +-
 .../primitivekeysservice/EdmTimeSet.java        |   7 +-
 .../services/primitivekeysservice/Folders.java  |   7 +-
 .../primitivekeysservice/TestContext.java       |   7 +-
 .../primitivekeysservice/types/EdmBinary.java   |  14 +-
 .../types/EdmBinaryCollection.java              |   6 +-
 .../primitivekeysservice/types/EdmBoolean.java  |  14 +-
 .../types/EdmBooleanCollection.java             |   6 +-
 .../primitivekeysservice/types/EdmByte.java     |  14 +-
 .../types/EdmByteCollection.java                |   6 +-
 .../primitivekeysservice/types/EdmDateTime.java |  14 +-
 .../types/EdmDateTimeCollection.java            |   6 +-
 .../types/EdmDateTimeOffset.java                |  14 +-
 .../types/EdmDateTimeOffsetCollection.java      |   6 +-
 .../primitivekeysservice/types/EdmDecimal.java  |  14 +-
 .../types/EdmDecimalCollection.java             |   6 +-
 .../primitivekeysservice/types/EdmDouble.java   |  14 +-
 .../types/EdmDoubleCollection.java              |   6 +-
 .../primitivekeysservice/types/EdmGuid.java     |  14 +-
 .../types/EdmGuidCollection.java                |   6 +-
 .../primitivekeysservice/types/EdmInt16.java    |  14 +-
 .../types/EdmInt16Collection.java               |   6 +-
 .../primitivekeysservice/types/EdmInt32.java    |  14 +-
 .../types/EdmInt32Collection.java               |   6 +-
 .../primitivekeysservice/types/EdmInt64.java    |  14 +-
 .../types/EdmInt64Collection.java               |   6 +-
 .../primitivekeysservice/types/EdmSingle.java   |  14 +-
 .../types/EdmSingleCollection.java              |   6 +-
 .../primitivekeysservice/types/EdmString.java   |  14 +-
 .../types/EdmStringCollection.java              |   6 +-
 .../primitivekeysservice/types/EdmTime.java     |  14 +-
 .../types/EdmTimeCollection.java                |   6 +-
 .../primitivekeysservice/types/Folder.java      |  14 +-
 .../types/FolderCollection.java                 |   6 +-
 .../AllGeoCollectionTypesSet.java               |   9 +-
 .../astoriadefaultservice/AllGeoTypesSet.java   |   7 +-
 .../services/astoriadefaultservice/Car.java     |   7 +-
 .../astoriadefaultservice/Computer.java         |   7 +-
 .../astoriadefaultservice/ComputerDetail.java   |   7 +-
 .../astoriadefaultservice/Customer.java         |   7 +-
 .../astoriadefaultservice/CustomerInfo.java     |   7 +-
 .../astoriadefaultservice/DefaultContainer.java |  45 +-----
 .../services/astoriadefaultservice/Driver.java  |   7 +-
 .../astoriadefaultservice/LastLogin.java        |   7 +-
 .../services/astoriadefaultservice/License.java |   7 +-
 .../services/astoriadefaultservice/Login.java   |   7 +-
 .../astoriadefaultservice/MappedEntityType.java |   7 +-
 .../services/astoriadefaultservice/Message.java |  11 +-
 .../MessageAttachment.java                      |   7 +-
 .../services/astoriadefaultservice/Order.java   |   7 +-
 .../astoriadefaultservice/OrderLine.java        |  15 +-
 .../astoriadefaultservice/PageView.java         |   9 +-
 .../services/astoriadefaultservice/Person.java  |  13 +-
 .../astoriadefaultservice/PersonMetadata.java   |   7 +-
 .../services/astoriadefaultservice/Product.java |   9 +-
 .../astoriadefaultservice/ProductDetail.java    |   7 +-
 .../astoriadefaultservice/ProductPhoto.java     |  11 +-
 .../astoriadefaultservice/ProductReview.java    |  11 +-
 .../astoriadefaultservice/RSAToken.java         |   7 +-
 .../astoriadefaultservice/types/Aliases.java    |  10 +-
 .../types/AllSpatialCollectionTypes.java        |  14 +-
 .../AllSpatialCollectionTypesCollection.java    |   6 +-
 .../types/AllSpatialCollectionTypes_Simple.java |  14 +-
 ...SpatialCollectionTypes_SimpleCollection.java |   6 +-
 .../types/AllSpatialTypes.java                  |  14 +-
 .../types/AllSpatialTypesCollection.java        |   6 +-
 .../astoriadefaultservice/types/AuditInfo.java  |  14 +-
 .../types/BackOrderLine.java                    |  14 +-
 .../types/BackOrderLine2.java                   |  14 +-
 .../types/BackOrderLine2Collection.java         |   6 +-
 .../types/BackOrderLineCollection.java          |   6 +-
 .../astoriadefaultservice/types/Car.java        |  14 +-
 .../types/CarCollection.java                    |   6 +-
 .../types/ComplexToCategory.java                |  10 +-
 .../types/ComplexWithAllPrimitiveTypes.java     |  10 +-
 .../astoriadefaultservice/types/Computer.java   |  16 +--
 .../types/ComputerCollection.java               |   6 +-
 .../types/ComputerDetail.java                   |  20 +--
 .../types/ComputerDetailCollection.java         |   6 +-
 .../types/ConcurrencyInfo.java                  |  10 +-
 .../types/ContactDetails.java                   |  26 +---
 .../astoriadefaultservice/types/Contractor.java |  14 +-
 .../types/ContractorCollection.java             |   6 +-
 .../astoriadefaultservice/types/Customer.java   |  26 +---
 .../types/CustomerCollection.java               |   6 +-
 .../types/CustomerInfo.java                     |  14 +-
 .../types/CustomerInfoCollection.java           |   6 +-
 .../astoriadefaultservice/types/Dimensions.java |  10 +-
 .../types/DiscontinuedProduct.java              |  30 +---
 .../types/DiscontinuedProductCollection.java    |   6 +-
 .../astoriadefaultservice/types/Driver.java     |  14 +-
 .../types/DriverCollection.java                 |   6 +-
 .../astoriadefaultservice/types/Employee.java   |  16 +--
 .../types/EmployeeCollection.java               |   6 +-
 .../astoriadefaultservice/types/LastLogin.java  |  14 +-
 .../types/LastLoginCollection.java              |   6 +-
 .../astoriadefaultservice/types/License.java    |  14 +-
 .../types/LicenseCollection.java                |   6 +-
 .../astoriadefaultservice/types/Login.java      |  14 +-
 .../types/LoginCollection.java                  |   6 +-
 .../types/MappedEntityType.java                 |  26 +---
 .../types/MappedEntityTypeCollection.java       |   6 +-
 .../astoriadefaultservice/types/Message.java    |  14 +-
 .../types/MessageAttachment.java                |  14 +-
 .../types/MessageAttachmentCollection.java      |   6 +-
 .../types/MessageCollection.java                |   6 +-
 .../astoriadefaultservice/types/MessageKey.java |   4 +-
 .../astoriadefaultservice/types/Order.java      |  18 +--
 .../types/OrderCollection.java                  |   6 +-
 .../astoriadefaultservice/types/OrderLine.java  |  14 +-
 .../types/OrderLineCollection.java              |   6 +-
 .../types/OrderLineKey.java                     |   4 +-
 .../astoriadefaultservice/types/PageView.java   |  14 +-
 .../types/PageViewCollection.java               |   6 +-
 .../astoriadefaultservice/types/Person.java     |  14 +-
 .../types/PersonCollection.java                 |   6 +-
 .../types/PersonMetadata.java                   |  14 +-
 .../types/PersonMetadataCollection.java         |   6 +-
 .../astoriadefaultservice/types/Phone.java      |  10 +-
 .../astoriadefaultservice/types/Product.java    |  28 +---
 .../types/ProductCollection.java                |   6 +-
 .../types/ProductDetail.java                    |  14 +-
 .../types/ProductDetailCollection.java          |   6 +-
 .../types/ProductPageView.java                  |  14 +-
 .../types/ProductPageViewCollection.java        |   6 +-
 .../types/ProductPhoto.java                     |  14 +-
 .../types/ProductPhotoCollection.java           |   6 +-
 .../types/ProductPhotoKey.java                  |   4 +-
 .../types/ProductReview.java                    |  14 +-
 .../types/ProductReviewCollection.java          |   6 +-
 .../types/ProductReviewKey.java                 |   4 +-
 .../astoriadefaultservice/types/RSAToken.java   |  14 +-
 .../types/RSATokenCollection.java               |   6 +-
 .../types/SpecialEmployee.java                  |  14 +-
 .../types/SpecialEmployeeCollection.java        |   6 +-
 .../fit/proxy/v4/APIBasicDesignTestITCase.java  |  54 ++++----
 .../olingo/fit/proxy/v4/AbstractTestITCase.java |  36 ++---
 .../olingo/fit/proxy/v4/AsyncTestITCase.java    |  23 ++--
 .../proxy/v4/AuthEntityCreateTestITCase.java    |  21 +--
 .../proxy/v4/AuthEntityRetrieveTestITCase.java  |  17 +--
 .../v4/BoundOperationInvokeTestITCase.java      |  39 +++---
 .../fit/proxy/v4/DerivedTypeTestITCase.java     |  37 +++--
 .../fit/proxy/v4/EntityCreateTestITCase.java    |  79 +++++------
 .../fit/proxy/v4/EntityRetrieveTestITCase.java  |  19 +--
 .../fit/proxy/v4/EntitySetTestITCase.java       |  17 +--
 .../fit/proxy/v4/EntityUpdateTestITCase.java    |  50 ++++---
 .../olingo/fit/proxy/v4/FilterTestITCase.java   |  25 ++--
 .../fit/proxy/v4/KeyAsSegmentTestITCase.java    |  17 +--
 .../fit/proxy/v4/MediaEntityTestITCase.java     |  36 ++---
 ...TransactionalAuthEntityCreateTestITCase.java |  21 +--
 .../NonTransactionalEntityCreateTestITCase.java |  21 +--
 .../NonTransactionalEntityUpdateTestITCase.java |  21 +--
 .../NonTransactionalMediaEntityTestITCase.java  |  21 +--
 .../olingo/fit/proxy/v4/OpenTypeTestITCase.java |  43 +++---
 .../v4/OperationImportInvokeTestITCase.java     |  30 ++--
 .../olingo/fit/proxy/v4/PropertyTestITCase.java |  19 +--
 .../fit/proxy/v4/SingletonTestITCase.java       |  17 +--
 .../v4/UnauthorizedEntityCreateTestITCase.java  |  17 +--
 .../proxy/v4/demo/odatademo/Advertisements.java |   7 +-
 .../fit/proxy/v4/demo/odatademo/Categories.java |   7 +-
 .../proxy/v4/demo/odatademo/DemoService.java    |  17 +--
 .../proxy/v4/demo/odatademo/PersonDetails.java  |   7 +-
 .../fit/proxy/v4/demo/odatademo/Persons.java    |  11 +-
 .../proxy/v4/demo/odatademo/ProductDetails.java |   7 +-
 .../fit/proxy/v4/demo/odatademo/Products.java   |   9 +-
 .../fit/proxy/v4/demo/odatademo/Suppliers.java  |   7 +-
 .../proxy/v4/demo/odatademo/types/Address.java  |   9 +-
 .../v4/demo/odatademo/types/Advertisement.java  |  14 +-
 .../types/AdvertisementCollection.java          |   6 +-
 .../proxy/v4/demo/odatademo/types/Category.java |  16 +--
 .../odatademo/types/CategoryCollection.java     |   6 +-
 .../proxy/v4/demo/odatademo/types/Customer.java |  14 +-
 .../odatademo/types/CustomerCollection.java     |   6 +-
 .../proxy/v4/demo/odatademo/types/Employee.java |  14 +-
 .../odatademo/types/EmployeeCollection.java     |   6 +-
 .../demo/odatademo/types/FeaturedProduct.java   |  14 +-
 .../types/FeaturedProductCollection.java        |   6 +-
 .../proxy/v4/demo/odatademo/types/Person.java   |  14 +-
 .../demo/odatademo/types/PersonCollection.java  |   6 +-
 .../v4/demo/odatademo/types/PersonDetail.java   |  18 +--
 .../odatademo/types/PersonDetailCollection.java |   6 +-
 .../proxy/v4/demo/odatademo/types/Product.java  |  16 +--
 .../demo/odatademo/types/ProductCollection.java |   6 +-
 .../v4/demo/odatademo/types/ProductDetail.java  |  14 +-
 .../types/ProductDetailCollection.java          |   6 +-
 .../proxy/v4/demo/odatademo/types/Supplier.java |  18 +--
 .../odatademo/types/SupplierCollection.java     |   6 +-
 .../opentypesservicev4/DefaultContainer.java    |  19 +--
 .../odata/services/opentypesservicev4/Row.java  |   9 +-
 .../services/opentypesservicev4/RowIndex.java   |   7 +-
 .../opentypesservicev4/types/AccountInfo.java   |   9 +-
 .../opentypesservicev4/types/Color.java         |   2 +
 .../types/ContactDetails.java                   |   9 +-
 .../opentypesservicev4/types/IndexedRow.java    |  16 +--
 .../types/IndexedRowCollection.java             |   6 +-
 .../services/opentypesservicev4/types/Row.java  |  16 +--
 .../opentypesservicev4/types/RowCollection.java |   6 +-
 .../opentypesservicev4/types/RowIndex.java      |  16 +--
 .../types/RowIndexCollection.java               |   6 +-
 .../services/odatawcfservice/Accounts.java      |   7 +-
 .../odata/services/odatawcfservice/Boss.java    |   4 +-
 .../odata/services/odatawcfservice/Company.java |   4 +-
 .../services/odatawcfservice/Customers.java     |   7 +-
 .../odatawcfservice/DefaultStoredPI.java        |   4 +-
 .../services/odatawcfservice/Departments.java   |   7 +-
 .../services/odatawcfservice/Employees.java     |   7 +-
 .../odatawcfservice/InMemoryEntities.java       |  29 +---
 .../services/odatawcfservice/LabourUnion.java   |   4 +-
 .../services/odatawcfservice/OrderDetails.java  |  10 +-
 .../odata/services/odatawcfservice/Orders.java  |   7 +-
 .../odata/services/odatawcfservice/People.java  |  11 +-
 .../odatawcfservice/ProductDetails.java         |  11 +-
 .../odatawcfservice/ProductReviews.java         |  11 +-
 .../services/odatawcfservice/Products.java      |   7 +-
 .../services/odatawcfservice/PublicCompany.java |   4 +-
 .../services/odatawcfservice/StoredPIs.java     |   7 +-
 .../odatawcfservice/SubscriptionTemplates.java  |   7 +-
 .../services/odatawcfservice/VipCustomer.java   |   4 +-
 .../odatawcfservice/types/AccessLevel.java      |   2 +
 .../services/odatawcfservice/types/Account.java |  34 ++---
 .../types/AccountCollection.java                |   6 +-
 .../odatawcfservice/types/AccountInfo.java      |   9 +-
 .../services/odatawcfservice/types/Address.java |   9 +-
 .../services/odatawcfservice/types/Asset.java   |  14 +-
 .../odatawcfservice/types/AssetCollection.java  |   6 +-
 .../services/odatawcfservice/types/Club.java    |  14 +-
 .../odatawcfservice/types/ClubCollection.java   |   6 +-
 .../services/odatawcfservice/types/Color.java   |   2 +
 .../services/odatawcfservice/types/Company.java |  22 +--
 .../odatawcfservice/types/CompanyAddress.java   |   9 +-
 .../odatawcfservice/types/CompanyCategory.java  |   2 +
 .../types/CompanyCollection.java                |   6 +-
 .../odatawcfservice/types/CreditCardPI.java     |  21 +--
 .../types/CreditCardPICollection.java           |   6 +-
 .../odatawcfservice/types/CreditRecord.java     |  14 +-
 .../types/CreditRecordCollection.java           |   6 +-
 .../odatawcfservice/types/Customer.java         |  18 +--
 .../types/CustomerCollection.java               |   6 +-
 .../odatawcfservice/types/Department.java       |  14 +-
 .../types/DepartmentCollection.java             |   6 +-
 .../odatawcfservice/types/Employee.java         |  18 +--
 .../types/EmployeeCollection.java               |   6 +-
 .../odatawcfservice/types/GiftCard.java         |  16 +--
 .../types/GiftCardCollection.java               |   6 +-
 .../odatawcfservice/types/HomeAddress.java      |   9 +-
 .../services/odatawcfservice/types/IsBoss.java  |   2 +
 .../odatawcfservice/types/LabourUnion.java      |  14 +-
 .../types/LabourUnionCollection.java            |   6 +-
 .../services/odatawcfservice/types/Order.java   |  14 +-
 .../odatawcfservice/types/OrderCollection.java  |   6 +-
 .../odatawcfservice/types/OrderDetail.java      |  14 +-
 .../types/OrderDetailCollection.java            |   6 +-
 .../odatawcfservice/types/OrderDetailKey.java   |   4 +-
 .../types/PaymentInstrument.java                |  21 +--
 .../types/PaymentInstrumentCollection.java      |   6 +-
 .../services/odatawcfservice/types/Person.java  |  20 +--
 .../odatawcfservice/types/PersonCollection.java |   6 +-
 .../services/odatawcfservice/types/Product.java |  16 +--
 .../types/ProductCollection.java                |   6 +-
 .../odatawcfservice/types/ProductDetail.java    |  16 +--
 .../types/ProductDetailCollection.java          |   6 +-
 .../odatawcfservice/types/ProductDetailKey.java |   4 +-
 .../odatawcfservice/types/ProductReview.java    |  14 +-
 .../types/ProductReviewCollection.java          |   6 +-
 .../odatawcfservice/types/ProductReviewKey.java |   4 +-
 .../odatawcfservice/types/PublicCompany.java    |  27 ++--
 .../types/PublicCompanyCollection.java          |   6 +-
 .../odatawcfservice/types/Statement.java        |  14 +-
 .../types/StatementCollection.java              |   6 +-
 .../odatawcfservice/types/StoredPI.java         |  14 +-
 .../types/StoredPICollection.java               |   6 +-
 .../odatawcfservice/types/Subscription.java     |  14 +-
 .../types/SubscriptionCollection.java           |   6 +-
 .../api/communication/request/ODataRequest.java |   8 ++
 .../request/AbstractODataRequest.java           |  33 +++--
 460 files changed, 2668 insertions(+), 3486 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/989babb1/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/Service.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/Service.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/Service.java
index e20ab40..a0babe8 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/Service.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/Service.java
@@ -21,13 +21,21 @@ package org.apache.olingo.ext.proxy;
 import org.apache.olingo.client.api.CommonEdmEnabledODataClient;
 import org.apache.olingo.client.core.ODataClientFactory;
 import org.apache.olingo.commons.api.format.ODataFormat;
+import org.apache.olingo.ext.proxy.api.ComplexType;
+import org.apache.olingo.ext.proxy.api.EntityCollection;
+import org.apache.olingo.ext.proxy.api.EntityType;
 import org.apache.olingo.ext.proxy.api.PersistenceManager;
+import org.apache.olingo.ext.proxy.commons.ComplexInvocationHandler;
+import org.apache.olingo.ext.proxy.commons.EntityCollectionInvocationHandler;
 import org.apache.olingo.ext.proxy.commons.EntityContainerInvocationHandler;
+import org.apache.olingo.ext.proxy.commons.EntityInvocationHandler;
 import org.apache.olingo.ext.proxy.commons.NonTransactionalPersistenceManagerImpl;
 import org.apache.olingo.ext.proxy.commons.TransactionalPersistenceManagerImpl;
 import org.apache.olingo.ext.proxy.context.Context;
+import org.apache.olingo.ext.proxy.utils.ClassUtils;
 
 import java.lang.reflect.Proxy;
+import java.util.ArrayList;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
@@ -105,7 +113,6 @@ public final class Service<C extends CommonEdmEnabledODataClient<?>> {
 
     return getInstance(ODataClientFactory.getEdmEnabledV4(serviceRoot), transactional);
   }
-
   private final CommonEdmEnabledODataClient<?> client;
 
   private final Context context;
@@ -162,4 +169,33 @@ public final class Service<C extends CommonEdmEnabledODataClient<?>> {
     }
     return reference.cast(ENTITY_CONTAINERS.get(reference));
   }
+
+  @SuppressWarnings("unchecked")
+  public <NE extends EntityType> NE newEntity(final Class<NE> reference) {
+    final EntityInvocationHandler handler = EntityInvocationHandler.getInstance(reference, this);
+
+    return (NE) Proxy.newProxyInstance(
+            Thread.currentThread().getContextClassLoader(),
+            new Class<?>[] {reference},
+            handler);
+  }
+
+  @SuppressWarnings("unchecked")
+  public <T extends EntityType, NEC extends EntityCollection<T>> NEC newEntityCollection(final Class<NEC> reference) {
+    final Class<T> ref = (Class<T>) ClassUtils.extractTypeArg(reference, EntityCollection.class);
+
+    return (NEC) Proxy.newProxyInstance(
+            Thread.currentThread().getContextClassLoader(),
+            new Class<?>[] {reference},
+            new EntityCollectionInvocationHandler<T>(this, new ArrayList<T>(), ref));
+  }
+
+  @SuppressWarnings("unchecked")
+  public <NE extends ComplexType> NE newComplex(final Class<NE> reference) {
+    return (NE) Proxy.newProxyInstance(
+            Thread.currentThread().getContextClassLoader(),
+            new Class<?>[] {reference},
+            ComplexInvocationHandler.getInstance(reference, this));
+
+  }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/989babb1/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/AbstractEntityCollection.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/AbstractEntityCollection.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/AbstractEntityCollection.java
deleted file mode 100644
index 39aba85..0000000
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/AbstractEntityCollection.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.ext.proxy.api;
-
-import java.io.Serializable;
-import java.util.Collection;
-
-public interface AbstractEntityCollection<T extends Serializable> extends Collection<T>, Serializable {
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/989babb1/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/AbstractEntitySet.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/AbstractEntitySet.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/AbstractEntitySet.java
index 93ab552..1455e87 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/AbstractEntitySet.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/AbstractEntitySet.java
@@ -24,9 +24,11 @@ import java.io.Serializable;
  * Interface for synchronous CRUD operations on an EntitySet.
  */
 public interface AbstractEntitySet<
-        T extends StructuredType, KEY extends Serializable, EC extends AbstractEntityCollection<T>>
+        T extends StructuredType, KEY extends Serializable, EC extends EntityCollection<T>>
         extends Iterable<T>, Serializable {
 
+  void add(final T entity);
+
   /**
    * Returns whether an entity with the given id exists.
    *
@@ -102,5 +104,5 @@ public interface AbstractEntitySet<
    * @param reference
    * @return the new search instance
    */
-  <S extends T, SEC extends AbstractEntityCollection<S>> Search<S, SEC> createSearch(Class<SEC> reference);
+  <S extends T, SEC extends EntityCollection<S>> Search<S, SEC> createSearch(Class<SEC> reference);
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/989babb1/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/AbstractSingleton.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/AbstractSingleton.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/AbstractSingleton.java
index 4468653..cfba4b9 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/AbstractSingleton.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/AbstractSingleton.java
@@ -21,6 +21,6 @@ package org.apache.olingo.ext.proxy.api;
 import java.io.Serializable;
 
 public interface AbstractSingleton<
-        T extends Serializable, KEY extends Serializable, EC extends AbstractEntityCollection<T>>
+        T extends Serializable, KEY extends Serializable, EC extends EntityCollection<T>>
         extends Serializable {
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/989babb1/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/CollectionQuery.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/CollectionQuery.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/CollectionQuery.java
index da44495..7793d78 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/CollectionQuery.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/CollectionQuery.java
@@ -21,7 +21,7 @@ package org.apache.olingo.ext.proxy.api;
 import org.apache.olingo.client.api.uri.URIFilter;
 
 public interface CollectionQuery<
-        T extends StructuredType, EC extends AbstractEntityCollection<T>, CT extends CollectionQuery<T, EC, ?>>
+        T extends StructuredType, EC extends EntityCollection<T>, CT extends CollectionQuery<T, EC, ?>>
         extends CommonQuery<CollectionQuery<T, EC, CT>> {
 
   /**

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/989babb1/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/ComplexType.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/ComplexType.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/ComplexType.java
new file mode 100644
index 0000000..37d5b2d
--- /dev/null
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/ComplexType.java
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.ext.proxy.api;
+
+public interface ComplexType extends StructuredType {
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/989babb1/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/EntityCollection.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/EntityCollection.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/EntityCollection.java
new file mode 100644
index 0000000..a0de7bc
--- /dev/null
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/EntityCollection.java
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.ext.proxy.api;
+
+import java.io.Serializable;
+import java.util.Collection;
+
+public interface EntityCollection<T extends Serializable> extends Collection<T>, Serializable {
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/989babb1/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/EntityCollectionQuery.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/EntityCollectionQuery.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/EntityCollectionQuery.java
index 09f22cb..534d4f5 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/EntityCollectionQuery.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/EntityCollectionQuery.java
@@ -19,7 +19,7 @@
 package org.apache.olingo.ext.proxy.api;
 
 public interface EntityCollectionQuery<
-        T extends StructuredType, EC extends AbstractEntityCollection<T>, CT extends EntityCollectionQuery<T, EC, ?>>
+        T extends StructuredType, EC extends EntityCollection<T>, CT extends EntityCollectionQuery<T, EC, ?>>
         extends CollectionQuery<T, EC, CT> {
 
   /**

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/989babb1/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/EntitySetQuery.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/EntitySetQuery.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/EntitySetQuery.java
index e635eca..bbd23b2 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/EntitySetQuery.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/EntitySetQuery.java
@@ -19,7 +19,7 @@
 package org.apache.olingo.ext.proxy.api;
 
 public interface EntitySetQuery<
-        T extends StructuredType, EC extends AbstractEntityCollection<T>, CT extends EntitySetQuery<T, EC, ?>>
+        T extends StructuredType, EC extends EntityCollection<T>, CT extends EntitySetQuery<T, EC, ?>>
         extends CollectionQuery<T, EC, CT> {
 
   /**
@@ -30,5 +30,5 @@ public interface EntitySetQuery<
    * @param reference entity collection class to be returned
    * @return all entities of the given subtype
    */
-  <S extends T, SEC extends AbstractEntityCollection<S>> SEC execute(Class<SEC> reference);
+  <S extends T, SEC extends EntityCollection<S>> SEC execute(Class<SEC> reference);
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/989babb1/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/EntityType.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/EntityType.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/EntityType.java
new file mode 100644
index 0000000..84336c1
--- /dev/null
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/EntityType.java
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.ext.proxy.api;
+
+public interface EntityType extends StructuredType {
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/989babb1/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/Search.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/Search.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/Search.java
index a03ed89..feec716 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/Search.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/Search.java
@@ -28,7 +28,7 @@ import java.io.Serializable;
  * @param <T> search result type
  * @param <EC>
  */
-public interface Search<T extends Serializable, EC extends AbstractEntityCollection<T>> extends Serializable {
+public interface Search<T extends Serializable, EC extends EntityCollection<T>> extends Serializable {
 
   /**
    * Sets the <tt>$search</tt> expression for this search.

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/989babb1/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/annotations/EntitySet.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/annotations/EntitySet.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/annotations/EntitySet.java
index 8da4baa..d27450f 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/annotations/EntitySet.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/annotations/EntitySet.java
@@ -33,5 +33,7 @@ public @interface EntitySet {
 
   String name();
 
+  String container() default "";
+
   boolean contained() default false;
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/989babb1/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/annotations/Singleton.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/annotations/Singleton.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/annotations/Singleton.java
index 3f85c88..0c96698 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/annotations/Singleton.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/annotations/Singleton.java
@@ -32,4 +32,6 @@ import java.lang.annotation.Target;
 public @interface Singleton {
 
   String name();
+
+  String container() default "";
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/989babb1/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractEntityCollectionInvocationHandler.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractEntityCollectionInvocationHandler.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractEntityCollectionInvocationHandler.java
index edf0eb6..2435e08 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractEntityCollectionInvocationHandler.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractEntityCollectionInvocationHandler.java
@@ -30,7 +30,7 @@ import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
 import org.apache.olingo.commons.api.domain.v4.ODataAnnotation;
 import org.apache.olingo.commons.api.domain.v4.ODataEntitySet;
 import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
-import org.apache.olingo.ext.proxy.api.AbstractEntityCollection;
+import org.apache.olingo.ext.proxy.api.EntityCollection;
 import org.apache.olingo.ext.proxy.api.AbstractEntitySet;
 import org.apache.olingo.ext.proxy.api.AbstractSingleton;
 import org.apache.olingo.ext.proxy.api.Sort;
@@ -42,9 +42,10 @@ import java.lang.reflect.Type;
 import java.net.URI;
 import java.util.ArrayList;
 import java.util.List;
+import org.apache.olingo.ext.proxy.Service;
 
 public abstract class AbstractEntityCollectionInvocationHandler<
-        T extends StructuredType, EC extends AbstractEntityCollection<T>>
+        T extends StructuredType, EC extends EntityCollection<T>>
         extends AbstractInvocationHandler {
 
   private static final long serialVersionUID = 98078202642671727L;
@@ -62,9 +63,9 @@ public abstract class AbstractEntityCollectionInvocationHandler<
   @SuppressWarnings("unchecked")
   public AbstractEntityCollectionInvocationHandler(
           final Class<?> ref,
-          final EntityContainerInvocationHandler containerHandler,
+          final Service<?> service,
           final CommonURIBuilder<?> uri) {
-    super(containerHandler);
+    super(service);
 
     this.uri = uri;
     this.baseURI = uri.build();
@@ -81,9 +82,9 @@ public abstract class AbstractEntityCollectionInvocationHandler<
   public AbstractEntityCollectionInvocationHandler(
           final Class<?> itemRef,
           final Class<EC> collItemRef,
-          final EntityContainerInvocationHandler containerHandler,
+          final Service<?> service,
           final CommonURIBuilder<?> uri) {
-    super(containerHandler);
+    super(service);
 
     this.uri = uri;
     this.baseURI = uri == null ? null : uri.build();
@@ -100,7 +101,7 @@ public abstract class AbstractEntityCollectionInvocationHandler<
   }
 
   @SuppressWarnings("unchecked")
-  public <S extends T, SEC extends AbstractEntityCollection<S>> SEC fetchWholeEntitySet(
+  public <S extends T, SEC extends EntityCollection<S>> SEC fetchWholeEntitySet(
           final CommonURIBuilder<?> uriBuilder, final Class<S> typeRef, final Class<SEC> collTypeRef) {
 
     final List<S> items = new ArrayList<S>();
@@ -115,7 +116,7 @@ public abstract class AbstractEntityCollectionInvocationHandler<
     }
 
     final EntityCollectionInvocationHandler<S> entityCollectionHandler =
-            new EntityCollectionInvocationHandler<S>(containerHandler, items, typeRef, uriBuilder);
+            new EntityCollectionInvocationHandler<S>(service, items, typeRef, uriBuilder);
     entityCollectionHandler.setAnnotations(annotations);
 
     return (SEC) Proxy.newProxyInstance(
@@ -168,7 +169,7 @@ public abstract class AbstractEntityCollectionInvocationHandler<
               entity,
               null,
               typeRef,
-              containerHandler);
+              service);
 
       final EntityInvocationHandler handlerInTheContext = getContext().entityContext().getEntity(handler.getUUID());
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/989babb1/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractInvocationHandler.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractInvocationHandler.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractInvocationHandler.java
index d06bfcd..b7c7b94 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractInvocationHandler.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractInvocationHandler.java
@@ -61,24 +61,18 @@ abstract class AbstractInvocationHandler implements InvocationHandler {
 
   private static final long serialVersionUID = 358520026931462958L;
 
-  protected Service<?> factory;
+  protected Service<?> service;
 
-  protected EntityContainerInvocationHandler containerHandler;
-
-  protected AbstractInvocationHandler(final Service<?> factory) {
-    this.factory = factory;
-  }
-
-  protected AbstractInvocationHandler(final EntityContainerInvocationHandler containerHandler) {
-    this.containerHandler = containerHandler;
+  protected AbstractInvocationHandler(final Service<?> service) {
+    this.service = service;
   }
 
   protected CommonEdmEnabledODataClient<?> getClient() {
-    return factory == null ? containerHandler.getFactory().getClient() : factory.getClient();
+    return service.getClient();
   }
 
   protected Context getContext() {
-    return factory == null ? containerHandler.getFactory().getContext() : factory.getContext();
+    return service.getContext();
   }
 
   protected boolean isSelfMethod(final Method method, final Object[] args) {
@@ -111,13 +105,13 @@ abstract class AbstractInvocationHandler implements InvocationHandler {
     final List<Object> items = new ArrayList<Object>();
 
     for (CommonODataEntity entityFromSet : entitySet.getEntities()) {
-      items.add(getEntityProxy(entityFromSet, entityContainerName, null, typeRef, null, checkInTheContext));
+      items.add(getEntityProxy(entityFromSet, entityContainerName, uri, typeRef, null, checkInTheContext));
     }
 
     return Proxy.newProxyInstance(
             Thread.currentThread().getContextClassLoader(),
             new Class<?>[] {typeCollectionRef},
-            new EntityCollectionInvocationHandler(containerHandler, items, typeRef,
+            new EntityCollectionInvocationHandler(service, items, typeRef,
             uri == null ? null : getClient().newURIBuilder(uri.toASCIIString())));
   }
 
@@ -128,7 +122,7 @@ abstract class AbstractInvocationHandler implements InvocationHandler {
     return Proxy.newProxyInstance(
             Thread.currentThread().getContextClassLoader(),
             new Class<?>[] {typeRef},
-            EntitySetInvocationHandler.getInstance(typeRef, containerHandler, uri));
+            EntitySetInvocationHandler.getInstance(typeRef, service, uri));
   }
 
   protected Object getEntityProxy(
@@ -139,7 +133,7 @@ abstract class AbstractInvocationHandler implements InvocationHandler {
           final String eTag,
           final boolean checkInTheContext) {
 
-    EntityInvocationHandler handler = EntityInvocationHandler.getInstance(entity, entitySetURI, type, containerHandler);
+    EntityInvocationHandler handler = EntityInvocationHandler.getInstance(entity, entitySetURI, type, service);
 
     if (StringUtils.isNotBlank(eTag)) {
       // override ETag into the wrapped object.
@@ -148,6 +142,7 @@ abstract class AbstractInvocationHandler implements InvocationHandler {
 
     if (checkInTheContext && getContext().entityContext().isAttached(handler)) {
       handler = getContext().entityContext().getEntity(handler.getUUID());
+      handler.setEntity(entity);
     } else {
       handler.attach(AttachedEntityStatus.ATTACHED, false);
     }
@@ -209,7 +204,7 @@ abstract class AbstractInvocationHandler implements InvocationHandler {
 
     // 2. IMPORTANT: flush any pending change *before* invoke if this operation is side effecting
     if (annotation.type() == OperationType.ACTION) {
-      containerHandler.getFactory().getPersistenceManager().flush();
+      service.getPersistenceManager().flush();
     }
 
     // 3. invoke

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/989babb1/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractPersistenceManager.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractPersistenceManager.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractPersistenceManager.java
index 50b1b54..d4799c9 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractPersistenceManager.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractPersistenceManager.java
@@ -61,10 +61,10 @@ abstract class AbstractPersistenceManager implements PersistenceManager {
 
   private static final long serialVersionUID = 2065240290461241515L;
 
-  protected final Service<?> factory;
+  protected final Service<?> service;
 
   AbstractPersistenceManager(final Service<?> factory) {
-    this.factory = factory;
+    this.service = factory;
   }
 
   protected abstract void doFlush(final PersistenceChanges changes, final TransactionItems items);
@@ -76,7 +76,7 @@ abstract class AbstractPersistenceManager implements PersistenceManager {
 
     int pos = 0;
     final List<EntityLinkDesc> delayedUpdates = new ArrayList<EntityLinkDesc>();
-    for (AttachedEntity attachedEntity : factory.getContext().entityContext()) {
+    for (AttachedEntity attachedEntity : service.getContext().entityContext()) {
       final AttachedEntityStatus status = attachedEntity.getStatus();
       if (((status != AttachedEntityStatus.ATTACHED
               && status != AttachedEntityStatus.LINKED) || attachedEntity.getEntity().isChanged())
@@ -91,7 +91,7 @@ abstract class AbstractPersistenceManager implements PersistenceManager {
 
     doFlush(changes, items);
 
-    factory.getContext().detachAll();
+    service.getContext().detachAll();
   }
 
   private ODataLink buildNavigationLink(final String name, final URI uri, final ODataLinkType type) {
@@ -99,11 +99,11 @@ abstract class AbstractPersistenceManager implements PersistenceManager {
 
     switch (type) {
       case ENTITY_NAVIGATION:
-        result = factory.getClient().getObjectFactory().newEntityNavigationLink(name, uri);
+        result = service.getClient().getObjectFactory().newEntityNavigationLink(name, uri);
         break;
 
       case ENTITY_SET_NAVIGATION:
-        result = factory.getClient().getObjectFactory().newEntitySetNavigationLink(name, uri);
+        result = service.getClient().getObjectFactory().newEntitySetNavigationLink(name, uri);
         break;
 
       default:
@@ -120,25 +120,24 @@ abstract class AbstractPersistenceManager implements PersistenceManager {
           final List<EntityLinkDesc> delayedUpdates,
           final PersistenceChanges changeset) {
 
-    LOG.debug("Process '{}'", handler);
-
     items.put(handler, null);
 
     final CommonODataEntity entity = handler.getEntity();
     entity.getNavigationLinks().clear();
 
-    final AttachedEntityStatus currentStatus = factory.getContext().entityContext().getStatus(handler);
+    final AttachedEntityStatus currentStatus = service.getContext().entityContext().getStatus(handler);
+    LOG.debug("Process '{}({})'", handler, currentStatus);
 
     if (AttachedEntityStatus.DELETED != currentStatus) {
       entity.getProperties().clear();
-      CoreUtils.addProperties(factory.getClient(), handler.getPropertyChanges(), entity);
+      CoreUtils.addProperties(service.getClient(), handler.getPropertyChanges(), entity);
 
       if (entity instanceof ODataEntity) {
         ((ODataEntity) entity).getAnnotations().clear();
-        CoreUtils.addAnnotations(factory.getClient(), handler.getAnnotations(), (ODataEntity) entity);
+        CoreUtils.addAnnotations(service.getClient(), handler.getAnnotations(), (ODataEntity) entity);
 
         for (Map.Entry<String, AnnotatableInvocationHandler> entry : handler.getPropAnnotatableHandlers().entrySet()) {
-          CoreUtils.addAnnotations(factory.getClient(),
+          CoreUtils.addAnnotations(service.getClient(),
                   entry.getValue().getAnnotations(), ((ODataEntity) entity).getProperty(entry.getKey()));
         }
       }
@@ -150,19 +149,28 @@ abstract class AbstractPersistenceManager implements PersistenceManager {
               : ODataLinkType.ENTITY_NAVIGATION;
 
       final Set<EntityInvocationHandler> toBeLinked = new HashSet<EntityInvocationHandler>();
+
       for (Object proxy : type == ODataLinkType.ENTITY_SET_NAVIGATION
               ? (Collection<?>) property.getValue() : Collections.singleton(property.getValue())) {
 
         final EntityInvocationHandler target = (EntityInvocationHandler) Proxy.getInvocationHandler(proxy);
 
-        final AttachedEntityStatus status = factory.getContext().entityContext().getStatus(target);
+        final AttachedEntityStatus status;
+        if (!service.getContext().entityContext().isAttached(target)) {
+          status = resolveNavigationLink(property.getKey(), target);
+        } else {
+          status = service.getContext().entityContext().getStatus(target);
+        }
+
+        LOG.debug("Found link to '{}({})'", target, status);
 
         final URI editLink = target.getEntity().getEditLink();
 
         if ((status == AttachedEntityStatus.ATTACHED || status == AttachedEntityStatus.LINKED) && !target.isChanged()) {
+          LOG.debug("Add link to '{}'", target);
           entity.addLink(buildNavigationLink(
                   property.getKey().name(),
-                  URIUtils.getURI(factory.getClient().getServiceRoot(), editLink.toASCIIString()), type));
+                  URIUtils.getURI(service.getClient().getServiceRoot(), editLink.toASCIIString()), type));
         } else {
           if (!items.contains(target)) {
             pos = processEntityContext(target, pos, items, delayedUpdates, changeset);
@@ -175,9 +183,10 @@ abstract class AbstractPersistenceManager implements PersistenceManager {
             LOG.debug("Schedule '{}' from '{}' to '{}'", type.name(), handler, target);
             toBeLinked.add(target);
           } else if (status == AttachedEntityStatus.CHANGED) {
+            LOG.debug("Changed: '{}' from '{}' to (${}) '{}'", type.name(), handler, targetPos, target);
             entity.addLink(buildNavigationLink(
                     property.getKey().name(),
-                    URIUtils.getURI(factory.getClient().getServiceRoot(), editLink.toASCIIString()), type));
+                    URIUtils.getURI(service.getClient().getServiceRoot(), editLink.toASCIIString()), type));
           } else {
             // create the link for the current object
             LOG.debug("'{}' from '{}' to (${}) '{}'", type.name(), handler, targetPos, target);
@@ -196,7 +205,7 @@ abstract class AbstractPersistenceManager implements PersistenceManager {
       for (Map.Entry<String, AnnotatableInvocationHandler> entry
               : handler.getNavPropAnnotatableHandlers().entrySet()) {
 
-        CoreUtils.addAnnotations(factory.getClient(),
+        CoreUtils.addAnnotations(service.getClient(),
                 entry.getValue().getAnnotations(),
                 (org.apache.olingo.commons.api.domain.v4.ODataLink) entity.getNavigationLink(entry.getKey()));
       }
@@ -217,10 +226,11 @@ abstract class AbstractPersistenceManager implements PersistenceManager {
           final URI targetURI = currentStatus == AttachedEntityStatus.NEW
                   ? URI.create("$" + startingPos)
                   : URIUtils.getURI(
-                          factory.getClient().getServiceRoot(), handler.getEntity().getEditLink().toASCIIString());
+                  service.getClient().getServiceRoot(), handler.getEntity().getEditLink().toASCIIString());
           queueUpdate(handler, targetURI, entity, changeset);
           pos++;
           items.put(handler, pos);
+          LOG.debug("{}: Update media properties for '{}' into the process queue", pos, handler);
         }
 
         // update media content
@@ -228,28 +238,30 @@ abstract class AbstractPersistenceManager implements PersistenceManager {
           final URI targetURI = currentStatus == AttachedEntityStatus.NEW
                   ? URI.create("$" + startingPos + "/$value")
                   : URIUtils.getURI(
-                          factory.getClient().getServiceRoot(),
-                          handler.getEntity().getEditLink().toASCIIString() + "/$value");
+                  service.getClient().getServiceRoot(),
+                  handler.getEntity().getEditLink().toASCIIString() + "/$value");
 
           queueUpdateMediaEntity(handler, targetURI, handler.getStreamChanges(), changeset);
 
           // update media info (use null key)
           pos++;
           items.put(null, pos);
+          LOG.debug("{}: Update media info for '{}' into the process queue", pos, handler);
         }
       }
 
       for (Map.Entry<String, InputStream> streamedChanges : handler.getStreamedPropertyChanges().entrySet()) {
         final URI targetURI = currentStatus == AttachedEntityStatus.NEW
                 ? URI.create("$" + startingPos) : URIUtils.getURI(
-                        factory.getClient().getServiceRoot(),
-                        CoreUtils.getMediaEditLink(streamedChanges.getKey(), entity).toASCIIString());
+                service.getClient().getServiceRoot(),
+                CoreUtils.getMediaEditLink(streamedChanges.getKey(), entity).toASCIIString());
 
         queueUpdateMediaResource(handler, targetURI, streamedChanges.getValue(), changeset);
 
         // update media info (use null key)
         pos++;
         items.put(handler, pos);
+        LOG.debug("{}: Update media info (null key) for '{}' into the process queue", pos, handler);
       }
     }
 
@@ -267,14 +279,14 @@ abstract class AbstractPersistenceManager implements PersistenceManager {
       items.put(delayedUpdate.getSource(), pos);
 
       final CommonODataEntity changes =
-              factory.getClient().getObjectFactory().newEntity(delayedUpdate.getSource().getEntity().getTypeName());
+              service.getClient().getObjectFactory().newEntity(delayedUpdate.getSource().getEntity().getTypeName());
 
-      AttachedEntityStatus status = factory.getContext().entityContext().getStatus(delayedUpdate.getSource());
+      AttachedEntityStatus status = service.getContext().entityContext().getStatus(delayedUpdate.getSource());
 
       final URI sourceURI;
       if (status == AttachedEntityStatus.CHANGED) {
         sourceURI = URIUtils.getURI(
-                factory.getClient().getServiceRoot(),
+                service.getClient().getServiceRoot(),
                 delayedUpdate.getSource().getEntity().getEditLink().toASCIIString());
       } else {
         int sourcePos = items.get(delayedUpdate.getSource());
@@ -282,21 +294,21 @@ abstract class AbstractPersistenceManager implements PersistenceManager {
       }
 
       for (EntityInvocationHandler target : delayedUpdate.getTargets()) {
-        status = factory.getContext().entityContext().getStatus(target);
+        status = service.getContext().entityContext().getStatus(target);
 
         final URI targetURI;
         if (status == AttachedEntityStatus.CHANGED) {
           targetURI = URIUtils.getURI(
-                  factory.getClient().getServiceRoot(), target.getEntity().getEditLink().toASCIIString());
+                  service.getClient().getServiceRoot(), target.getEntity().getEditLink().toASCIIString());
         } else {
           int targetPos = items.get(target);
           targetURI = URI.create("$" + targetPos);
         }
 
         changes.addLink(delayedUpdate.getType() == ODataLinkType.ENTITY_NAVIGATION
-                ? factory.getClient().getObjectFactory().
+                ? service.getClient().getObjectFactory().
                 newEntityNavigationLink(delayedUpdate.getSourceName(), targetURI)
-                : factory.getClient().getObjectFactory().
+                : service.getClient().getObjectFactory().
                 newEntitySetNavigationLink(delayedUpdate.getSourceName(), targetURI));
 
         LOG.debug("'{}' from {} to {}", delayedUpdate.getType().name(), sourceURI, targetURI);
@@ -311,7 +323,7 @@ abstract class AbstractPersistenceManager implements PersistenceManager {
           final CommonODataEntity entity,
           final PersistenceChanges changeset) {
 
-    switch (factory.getContext().entityContext().getStatus(handler)) {
+    switch (service.getContext().entityContext().getStatus(handler)) {
       case NEW:
         queueCreate(handler, entity, changeset);
         return AttachedEntityStatus.NEW;
@@ -339,7 +351,7 @@ abstract class AbstractPersistenceManager implements PersistenceManager {
 
     LOG.debug("Create '{}'", handler);
 
-    changeset.addChange(factory.getClient().getCUDRequestFactory().
+    changeset.addChange(service.getClient().getCUDRequestFactory().
             getEntityCreateRequest(handler.getEntitySetURI(), entity), handler);
   }
 
@@ -352,7 +364,7 @@ abstract class AbstractPersistenceManager implements PersistenceManager {
     LOG.debug("Update media entity '{}'", uri);
 
     final ODataMediaEntityUpdateRequest<?> req =
-            factory.getClient().getCUDRequestFactory().getMediaEntityUpdateRequest(uri, input);
+            service.getClient().getCUDRequestFactory().getMediaEntityUpdateRequest(uri, input);
 
     if (StringUtils.isNotBlank(handler.getEntity().getMediaContentType())) {
       req.setContentType(ODataFormat.fromString(handler.getEntity().getMediaContentType()).toString());
@@ -373,7 +385,7 @@ abstract class AbstractPersistenceManager implements PersistenceManager {
 
     LOG.debug("Update media entity '{}'", uri);
 
-    final ODataStreamUpdateRequest req = factory.getClient().getCUDRequestFactory().getStreamUpdateRequest(uri, input);
+    final ODataStreamUpdateRequest req = service.getClient().getCUDRequestFactory().getStreamUpdateRequest(uri, input);
 
     if (StringUtils.isNotBlank(handler.getETag())) {
       req.setIfMatch(handler.getETag());
@@ -390,15 +402,15 @@ abstract class AbstractPersistenceManager implements PersistenceManager {
     LOG.debug("Update '{}'", handler.getEntityURI());
 
     final ODataEntityUpdateRequest<CommonODataEntity> req =
-            factory.getClient().getServiceVersion().compareTo(ODataServiceVersion.V30) <= 0
-            ? ((org.apache.olingo.client.api.v3.EdmEnabledODataClient) factory.getClient()).getCUDRequestFactory().
+            service.getClient().getServiceVersion().compareTo(ODataServiceVersion.V30) <= 0
+            ? ((org.apache.olingo.client.api.v3.EdmEnabledODataClient) service.getClient()).getCUDRequestFactory().
             getEntityUpdateRequest(handler.getEntityURI(),
-                    org.apache.olingo.client.api.communication.request.cud.v3.UpdateType.PATCH, changes)
-            : ((org.apache.olingo.client.api.v4.EdmEnabledODataClient) factory.getClient()).getCUDRequestFactory().
+            org.apache.olingo.client.api.communication.request.cud.v3.UpdateType.PATCH, changes)
+            : ((org.apache.olingo.client.api.v4.EdmEnabledODataClient) service.getClient()).getCUDRequestFactory().
             getEntityUpdateRequest(handler.getEntityURI(),
-                    org.apache.olingo.client.api.communication.request.cud.v4.UpdateType.PATCH, changes);
+            org.apache.olingo.client.api.communication.request.cud.v4.UpdateType.PATCH, changes);
 
-    req.setPrefer(new ODataPreferences(factory.getClient().getServiceVersion()).returnContent());
+    req.setPrefer(new ODataPreferences(service.getClient().getServiceVersion()).returnContent());
 
     if (StringUtils.isNotBlank(handler.getETag())) {
       req.setIfMatch(handler.getETag());
@@ -416,15 +428,15 @@ abstract class AbstractPersistenceManager implements PersistenceManager {
     LOG.debug("Update '{}'", uri);
 
     final ODataEntityUpdateRequest<CommonODataEntity> req =
-            factory.getClient().getServiceVersion().compareTo(ODataServiceVersion.V30) <= 0
-            ? ((org.apache.olingo.client.api.v3.EdmEnabledODataClient) factory.getClient()).getCUDRequestFactory().
+            service.getClient().getServiceVersion().compareTo(ODataServiceVersion.V30) <= 0
+            ? ((org.apache.olingo.client.api.v3.EdmEnabledODataClient) service.getClient()).getCUDRequestFactory().
             getEntityUpdateRequest(uri,
-                    org.apache.olingo.client.api.communication.request.cud.v3.UpdateType.PATCH, changes)
-            : ((org.apache.olingo.client.api.v4.EdmEnabledODataClient) factory.getClient()).getCUDRequestFactory().
+            org.apache.olingo.client.api.communication.request.cud.v3.UpdateType.PATCH, changes)
+            : ((org.apache.olingo.client.api.v4.EdmEnabledODataClient) service.getClient()).getCUDRequestFactory().
             getEntityUpdateRequest(uri,
-                    org.apache.olingo.client.api.communication.request.cud.v4.UpdateType.PATCH, changes);
+            org.apache.olingo.client.api.communication.request.cud.v4.UpdateType.PATCH, changes);
 
-    req.setPrefer(new ODataPreferences(factory.getClient().getServiceVersion()).returnContent());
+    req.setPrefer(new ODataPreferences(service.getClient().getServiceVersion()).returnContent());
 
     if (StringUtils.isNotBlank(handler.getETag())) {
       req.setIfMatch(handler.getETag());
@@ -438,10 +450,10 @@ abstract class AbstractPersistenceManager implements PersistenceManager {
           final CommonODataEntity entity,
           final PersistenceChanges changeset) {
 
-    final URI deleteURI = handler.getEntityURI() == null ? entity.getEditLink() : handler.getEntityURI();
+    final URI deleteURI = entity.getEditLink() == null ? handler.getEntityURI() : entity.getEditLink();
     LOG.debug("Delete '{}'", deleteURI);
 
-    final ODataDeleteRequest req = factory.getClient().getCUDRequestFactory().getDeleteRequest(deleteURI);
+    final ODataDeleteRequest req = service.getClient().getCUDRequestFactory().getDeleteRequest(deleteURI);
 
     if (StringUtils.isNotBlank(handler.getETag())) {
       req.setIfMatch(handler.getETag());
@@ -449,4 +461,18 @@ abstract class AbstractPersistenceManager implements PersistenceManager {
 
     changeset.addChange(req, handler);
   }
+
+  private AttachedEntityStatus resolveNavigationLink(
+          final NavigationProperty property, final EntityInvocationHandler handler) {
+    if (handler.getUUID().getEntitySetURI() == null) {
+      final Object key = CoreUtils.getKey(service.getClient(), handler, handler.getTypeRef(), handler.getEntity());
+      handler.updateUUID(CoreUtils.getTargetEntitySetURI(service.getClient(), property), handler.getTypeRef(), null);
+      service.getContext().entityContext().attach(handler, AttachedEntityStatus.NEW);
+      return AttachedEntityStatus.NEW;
+    } else {
+      // existent object
+      service.getContext().entityContext().attach(handler, AttachedEntityStatus.LINKED);
+      return AttachedEntityStatus.LINKED;
+    }
+  }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/989babb1/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractStructuredInvocationHandler.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractStructuredInvocationHandler.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractStructuredInvocationHandler.java
index b4b58d7..ffc166b 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractStructuredInvocationHandler.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractStructuredInvocationHandler.java
@@ -19,18 +19,15 @@
 package org.apache.olingo.ext.proxy.commons;
 
 import org.apache.commons.lang3.ArrayUtils;
-import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest;
-import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
 import org.apache.olingo.client.core.uri.URIUtils;
 import org.apache.olingo.commons.api.domain.CommonODataEntity;
 import org.apache.olingo.commons.api.domain.ODataInlineEntity;
 import org.apache.olingo.commons.api.domain.ODataInlineEntitySet;
 import org.apache.olingo.commons.api.domain.ODataLink;
 import org.apache.olingo.commons.api.domain.ODataLinked;
-import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
-import org.apache.olingo.ext.proxy.api.AbstractEntityCollection;
+import org.apache.olingo.ext.proxy.Service;
+import org.apache.olingo.ext.proxy.api.EntityCollection;
 import org.apache.olingo.ext.proxy.api.AbstractEntitySet;
-import org.apache.olingo.ext.proxy.api.annotations.EntityType;
 import org.apache.olingo.ext.proxy.api.annotations.NavigationProperty;
 import org.apache.olingo.ext.proxy.api.annotations.Property;
 import org.apache.olingo.ext.proxy.context.AttachedEntityStatus;
@@ -38,16 +35,19 @@ import org.apache.olingo.ext.proxy.utils.ClassUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.Method;
 import java.lang.reflect.ParameterizedType;
 import java.lang.reflect.Proxy;
 import java.lang.reflect.Type;
 import java.net.URI;
 import java.util.Collection;
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
+import org.apache.olingo.client.api.uri.CommonURIBuilder;
+import org.apache.olingo.commons.api.edm.FullQualifiedName;
+import org.apache.olingo.ext.proxy.api.annotations.Namespace;
+import org.apache.olingo.ext.proxy.context.EntityUUID;
+import org.apache.olingo.ext.proxy.utils.CoreUtils;
 
 public abstract class AbstractStructuredInvocationHandler extends AbstractInvocationHandler {
 
@@ -58,6 +58,8 @@ public abstract class AbstractStructuredInvocationHandler extends AbstractInvoca
    */
   protected static final Logger LOG = LoggerFactory.getLogger(AbstractStructuredInvocationHandler.class);
 
+  protected CommonURIBuilder<?> uri;
+
   protected final Class<?> typeRef;
 
   protected EntityInvocationHandler entityHandler;
@@ -72,10 +74,20 @@ public abstract class AbstractStructuredInvocationHandler extends AbstractInvoca
 
   protected AbstractStructuredInvocationHandler(
           final Class<?> typeRef,
+          final Service<?> service) {
+
+    super(service);
+    this.internal = null;
+    this.typeRef = typeRef;
+    this.entityHandler = null;
+  }
+
+  protected AbstractStructuredInvocationHandler(
+          final Class<?> typeRef,
           final Object internal,
-          final EntityContainerInvocationHandler containerHandler) {
+          final Service<?> service) {
 
-    super(containerHandler);
+    super(service);
     this.internal = internal;
     this.typeRef = typeRef;
     this.entityHandler = null;
@@ -86,7 +98,7 @@ public abstract class AbstractStructuredInvocationHandler extends AbstractInvoca
           final Object internal,
           final EntityInvocationHandler entityHandler) {
 
-    super(entityHandler == null ? null : entityHandler.containerHandler);
+    super(entityHandler == null ? null : entityHandler.service);
     this.internal = internal;
     this.typeRef = typeRef;
     // prevent memory leak
@@ -123,6 +135,7 @@ public abstract class AbstractStructuredInvocationHandler extends AbstractInvoca
       return invokeSelfMethod(method, args);
     } else if ("load".equals(method.getName()) && ArrayUtils.isEmpty(args)) {
       load();
+      attach(); // attach the current handler
       return proxy;
     } else if ("operations".equals(method.getName()) && ArrayUtils.isEmpty(args)) {
       final Class<?> returnType = method.getReturnType();
@@ -131,13 +144,6 @@ public abstract class AbstractStructuredInvocationHandler extends AbstractInvoca
               Thread.currentThread().getContextClassLoader(),
               new Class<?>[] {returnType},
               OperationInvocationHandler.getInstance(getEntityHandler()));
-    } else if ("factory".equals(method.getName()) && ArrayUtils.isEmpty(args)) {
-      final Class<?> returnType = method.getReturnType();
-
-      return Proxy.newProxyInstance(
-              Thread.currentThread().getContextClassLoader(),
-              new Class<?>[] {returnType},
-              ComplexFactoryInvocationHandler.getInstance(getEntityHandler(), this));
     } else if ("annotations".equals(method.getName()) && ArrayUtils.isEmpty(args)) {
       final Class<?> returnType = method.getReturnType();
 
@@ -165,9 +171,6 @@ public abstract class AbstractStructuredInvocationHandler extends AbstractInvoca
         res = getPropertyValue(property.name(), getter.getGenericReturnType());
       }
 
-      // attach the current handler
-      attach();
-
       return res;
     } else if (method.getName().startsWith("set")) {
       // get the corresponding getter method (see assumption above)
@@ -198,9 +201,7 @@ public abstract class AbstractStructuredInvocationHandler extends AbstractInvoca
   }
 
   protected void attach() {
-    if (entityHandler != null && !getContext().entityContext().isAttached(getEntityHandler())) {
-      getContext().entityContext().attach(getEntityHandler(), AttachedEntityStatus.ATTACHED);
-    }
+    attach(AttachedEntityStatus.ATTACHED, false);
   }
 
   protected void attach(final AttachedEntityStatus status) {
@@ -222,7 +223,7 @@ public abstract class AbstractStructuredInvocationHandler extends AbstractInvoca
   protected Object retrieveNavigationProperty(final NavigationProperty property, final Method getter) {
     final Class<?> type = getter.getReturnType();
     final Class<?> collItemType;
-    if (AbstractEntityCollection.class.isAssignableFrom(type)) {
+    if (EntityCollection.class.isAssignableFrom(type)) {
       final Type[] eCollParams = ((ParameterizedType) type.getGenericInterfaces()[0]).getActualTypeArguments();
       collItemType = (Class<?>) eCollParams[0];
     } else {
@@ -254,7 +255,7 @@ public abstract class AbstractStructuredInvocationHandler extends AbstractInvoca
       // navigate
       final URI uri = URIUtils.getURI(getEntityHandler().getEntityURI(), property.name());
 
-      if (AbstractEntityCollection.class.isAssignableFrom(type)) {
+      if (EntityCollection.class.isAssignableFrom(type)) {
         navPropValue = getEntityCollectionProxy(
                 collItemType,
                 type,
@@ -265,20 +266,30 @@ public abstract class AbstractStructuredInvocationHandler extends AbstractInvoca
       } else if (AbstractEntitySet.class.isAssignableFrom(type)) {
         navPropValue = getEntitySetProxy(type, uri);
       } else {
-        final ODataEntityRequest<CommonODataEntity> req = getClient().getRetrieveRequestFactory().getEntityRequest(uri);
-        if (getClient().getServiceVersion().compareTo(ODataServiceVersion.V30) > 0) {
-          req.setPrefer(getClient().newPreferences().includeAnnotations("*"));
-        }
+        URI entitySetURI = CoreUtils.getTargetEntitySetURI(getClient(), property);
 
-        final ODataRetrieveResponse<CommonODataEntity> res = req.execute();
+        final EntityUUID uuid = new EntityUUID(entitySetURI, collItemType, null);
+        LOG.debug("Ask for '{}({})'", collItemType.getSimpleName(), null);
 
-        navPropValue = getEntityProxy(
-                res.getBody(),
-                property.targetContainer(),
-                getClient().newURIBuilder().appendEntitySetSegment(property.targetEntitySet()).build(),
-                type,
-                res.getETag(),
-                true);
+        EntityInvocationHandler handler = getContext().entityContext().getEntity(uuid);
+
+        if (handler == null) {
+          final CommonODataEntity entity = getClient().getObjectFactory().newEntity(new FullQualifiedName(
+                  collItemType.getAnnotation(Namespace.class).value(), ClassUtils.getEntityTypeName(collItemType)));
+
+          handler = EntityInvocationHandler.getInstance(
+                  entity, URIUtils.getURI(this.uri.build(), property.name()), entitySetURI, collItemType, service);
+
+        } else if (getContext().entityContext().getStatus(handler) == AttachedEntityStatus.DELETED) {
+          // object deleted
+          LOG.debug("Object '{}({})' has been deleted", collItemType.getSimpleName(), uuid);
+          handler = null;
+        }
+
+        navPropValue = handler == null ? null : Proxy.newProxyInstance(
+                Thread.currentThread().getContextClassLoader(),
+                new Class<?>[] {collItemType},
+                handler);
       }
     }
 
@@ -297,26 +308,7 @@ public abstract class AbstractStructuredInvocationHandler extends AbstractInvoca
       getContext().entityContext().attach(getEntityHandler(), AttachedEntityStatus.CHANGED);
     }
 
-    // 2) attach the target entity handlers
-    for (Object link : AbstractEntityCollection.class.isAssignableFrom(value.getClass())
-            ? (AbstractEntityCollection) value : Collections.singleton(value)) {
-
-      final InvocationHandler etih = Proxy.getInvocationHandler(link);
-      if (!(etih instanceof EntityInvocationHandler)) {
-        throw new IllegalArgumentException("Invalid argument type");
-      }
-
-      final EntityInvocationHandler linkedHandler = (EntityInvocationHandler) etih;
-      if (!linkedHandler.getTypeRef().isAnnotationPresent(EntityType.class)) {
-        throw new IllegalArgumentException("Invalid argument type " + linkedHandler.getTypeRef().getSimpleName());
-      }
-
-      if (!getContext().entityContext().isAttached(linkedHandler)) {
-        getContext().entityContext().attach(linkedHandler, AttachedEntityStatus.LINKED);
-      }
-    }
-
-    // 3) add links
+    // 2) add links
     addLinkChanges(property, value);
   }
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/989babb1/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AnnotatableInvocationHandler.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AnnotatableInvocationHandler.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AnnotatableInvocationHandler.java
index 5a36dd9..a1ab4b2 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AnnotatableInvocationHandler.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AnnotatableInvocationHandler.java
@@ -36,6 +36,7 @@ import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import org.apache.olingo.ext.proxy.Service;
 
 public class AnnotatableInvocationHandler extends AbstractInvocationHandler implements Annotatable {
 
@@ -53,13 +54,13 @@ public class AnnotatableInvocationHandler extends AbstractInvocationHandler impl
           new HashMap<Class<? extends AbstractTerm>, Object>();
 
   public AnnotatableInvocationHandler(
-          final EntityContainerInvocationHandler containerHandler,
+          final Service<?> service,
           final String propName,
           final String navPropName,
           final EntityInvocationHandler entityHandler,
           final AbstractStructuredInvocationHandler targetHandler) {
 
-    super(containerHandler);
+    super(service);
 
     this.propName = propName;
     this.navPropName = navPropName;
@@ -158,7 +159,7 @@ public class AnnotatableInvocationHandler extends AbstractInvocationHandler impl
         res = annotation == null || annotation.hasNullValue()
                 ? null
                 : CoreUtils.getObjectFromODataValue(
-                        getClient(), annotation.getValue(), null, targetHandler.getEntityHandler());
+                getClient(), annotation.getValue(), null, targetHandler.getEntityHandler());
         if (res != null) {
           annotations.put(term, res);
         }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/989babb1/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AnnotatationsInvocationHandler.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AnnotatationsInvocationHandler.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AnnotatationsInvocationHandler.java
index f87a0a5..133ba6b 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AnnotatationsInvocationHandler.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AnnotatationsInvocationHandler.java
@@ -24,6 +24,7 @@ import org.apache.olingo.ext.proxy.utils.ClassUtils;
 
 import java.lang.reflect.Method;
 import java.lang.reflect.Proxy;
+import org.apache.olingo.ext.proxy.Service;
 
 public class AnnotatationsInvocationHandler extends AbstractInvocationHandler {
 
@@ -39,17 +40,17 @@ public class AnnotatationsInvocationHandler extends AbstractInvocationHandler {
 
     return new AnnotatationsInvocationHandler(
             targetHandler == null
-            ? entityHandler == null ? null : entityHandler.containerHandler : targetHandler.containerHandler,
+            ? entityHandler == null ? null : entityHandler.service : targetHandler.service,
             entityHandler,
             targetHandler);
   }
 
   private AnnotatationsInvocationHandler(
-          final EntityContainerInvocationHandler containerHandler,
+          final Service<?> service,
           final EntityInvocationHandler entityHandler,
           final AbstractStructuredInvocationHandler targetHandler) {
 
-    super(containerHandler);
+    super(service);
     this.targetHandler = targetHandler;
     this.entityHandler = entityHandler;
   }
@@ -80,7 +81,7 @@ public class AnnotatationsInvocationHandler extends AbstractInvocationHandler {
       return Proxy.newProxyInstance(
               Thread.currentThread().getContextClassLoader(),
               new Class<?>[] {method.getReturnType()},
-              new AnnotatableInvocationHandler(containerHandler, propName, navPropName, entityHandler, targetHandler));
+              new AnnotatableInvocationHandler(service, propName, navPropName, entityHandler, targetHandler));
     } else {
       throw new NoSuchMethodException(method.getName());
     }