You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by tb...@apache.org on 2014/01/02 13:47:27 UTC

[40/47] [OLINGO-99] Re-factor Package Names. Following are the changes

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/63b621a8/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/exception/ODataJPAException.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/exception/ODataJPAException.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/exception/ODataJPAException.java
new file mode 100644
index 0000000..5258edd
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/exception/ODataJPAException.java
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * 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.odata2.jpa.processor.api.exception;
+
+import java.util.Locale;
+
+import org.apache.olingo.odata2.api.exception.MessageReference;
+import org.apache.olingo.odata2.api.exception.ODataException;
+
+/**
+ * The exception class is the base of OData JPA exceptions. The class also
+ * provides non localized error texts that can be used for raising OData JPA
+ * exceptions with non localized error texts.
+ * 
+ * 
+ * 
+ */
+public abstract class ODataJPAException extends ODataException {
+
+  protected MessageReference messageReference;
+
+  public static final String ODATA_JPACTX_NULL = "OData JPA Context cannot be null";
+
+  private static final long serialVersionUID = -6884673558124441214L;
+  protected static final Locale DEFAULT_LOCALE = Locale.ENGLISH;
+
+  protected ODataJPAException(final String localizedMessage, final Throwable e, final MessageReference msgRef) {
+    super(localizedMessage, e);
+    messageReference = msgRef;
+  }
+
+  /**
+   * The method creates a Reference to Message Object {@link org.apache.olingo.odata2.api.exception.MessageReference} .
+   * The message
+   * text key is derived out of parameters clazz.messageReferenceKey.
+   * 
+   * @param clazz
+   * is name of the class extending {@link org.apache.olingo.odata2.jpa.processor.api.exception.ODataJPAException}
+   * @param messageReferenceKey
+   * is the key of the message
+   * @return an instance of type {@link org.apache.olingo.odata2.api.exception.MessageReference}
+   */
+  protected static MessageReference createMessageReference(final Class<? extends ODataJPAException> clazz,
+      final String messageReferenceKey) {
+    return MessageReference.create(clazz, messageReferenceKey);
+  }
+
+  public MessageReference getMessageReference() {
+    return messageReference;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/63b621a8/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/exception/ODataJPAMessageService.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/exception/ODataJPAMessageService.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/exception/ODataJPAMessageService.java
new file mode 100644
index 0000000..6a7b166
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/exception/ODataJPAMessageService.java
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * 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.odata2.jpa.processor.api.exception;
+
+import org.apache.olingo.odata2.api.exception.MessageReference;
+
+/**
+ * The interface is used to access language dependent message texts. Default
+ * language is "English - EN". <br>
+ * The default implementation of the interface shipped with the library loads
+ * message texts from language dependent property files. If the message text is
+ * not found for the given language then the default language -EN is used for
+ * the message texts.
+ * 
+ * 
+ * @see org.apache.olingo.odata2.jpa.processor.api.exception.ODataJPAException
+ * @see org.apache.olingo.odata2.jpa.processor.api.exception.ODataJPARuntimeException
+ * @see org.apache.olingo.odata2.jpa.processor.api.exception.ODataJPAModelException
+ * @see org.apache.olingo.odata2.api.exception.MessageReference
+ */
+public interface ODataJPAMessageService {
+  /**
+   * The method returns a language dependent message texts for the given
+   * {@link org.apache.olingo.odata2.api.exception.MessageReference}.
+   * 
+   * @param context
+   * is a Message Reference
+   * exception
+   * is a Throwable Exception
+   * @return a language dependent message text
+   */
+  public String getLocalizedMessage(MessageReference context, Throwable exception);
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/63b621a8/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/exception/ODataJPAModelException.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/exception/ODataJPAModelException.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/exception/ODataJPAModelException.java
new file mode 100644
index 0000000..9f18f37
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/exception/ODataJPAModelException.java
@@ -0,0 +1,92 @@
+/*******************************************************************************
+ * 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.odata2.jpa.processor.api.exception;
+
+import org.apache.olingo.odata2.api.exception.MessageReference;
+import org.apache.olingo.odata2.jpa.processor.api.factory.ODataJPAFactory;
+
+/**
+ * The exception is thrown for any unexpected errors raising while
+ * accessing/transforming Java Persistence Models.
+ * 
+ * 
+ * 
+ */
+public class ODataJPAModelException extends ODataJPAException {
+
+  public static final MessageReference INVALID_ENTITY_TYPE = createMessageReference(ODataJPAModelException.class,
+      "INVALID_ENTITY_TYPE");
+  public static final MessageReference INVALID_COMPLEX_TYPE = createMessageReference(ODataJPAModelException.class,
+      "INVLAID_COMPLEX_TYPE");
+  public static final MessageReference INVALID_ASSOCIATION = createMessageReference(ODataJPAModelException.class,
+      "INVALID_ASSOCIATION");
+  public static final MessageReference INVALID_ENTITYSET = createMessageReference(ODataJPAModelException.class,
+      "INVALID_ENTITYSET");
+  public static final MessageReference INVALID_ENTITYCONTAINER = createMessageReference(ODataJPAModelException.class,
+      "INVALID_ENTITYCONTAINER");
+  public static final MessageReference INVALID_ASSOCIATION_SET = createMessageReference(ODataJPAModelException.class,
+      "INVALID_ASSOCIATION_SET");
+  public static final MessageReference INVALID_FUNC_IMPORT = createMessageReference(ODataJPAModelException.class,
+      "INVALID_FUNC_IMPORT");
+
+  public static final MessageReference BUILDER_NULL = createMessageReference(ODataJPAModelException.class,
+      "BUILDER_NULL");
+  public static final MessageReference TYPE_NOT_SUPPORTED = createMessageReference(ODataJPAModelException.class,
+      "TYPE_NOT_SUPPORTED");
+  public static final MessageReference FUNC_ENTITYSET_EXP = createMessageReference(ODataJPAModelException.class,
+      "FUNC_ENTITYSET_EXP");
+  public static final MessageReference FUNC_RETURN_TYPE_EXP = createMessageReference(ODataJPAModelException.class,
+      "FUNC_RETURN_TYPE_EXP");
+  public static final MessageReference FUNC_RETURN_TYPE_ENTITY_NOT_FOUND = createMessageReference(
+      ODataJPAModelException.class, "FUNC_RETURN_TYPE_ENTITY_NOT_FOUND");
+  public static final MessageReference GENERAL = createMessageReference(ODataJPAModelException.class, "GENERAL");
+  public static final MessageReference INNER_EXCEPTION = createMessageReference(ODataJPAModelException.class,
+      "INNER_EXCEPTION");
+  public static final MessageReference FUNC_PARAM_NAME_EXP = createMessageReference(ODataJPAModelException.class,
+      "FUNC_PARAM_NAME_EXP");
+
+  private ODataJPAModelException(final String localizedMessage, final Throwable e, final MessageReference msgRef) {
+    super(localizedMessage, e, msgRef);
+  }
+
+  /**
+   * The method creates an exception object of type ODataJPAModelException
+   * with localized error texts.
+   * 
+   * @param messageReference
+   * is a <b>mandatory</b> parameter referring to a literal that
+   * could be translated to localized error texts.
+   * @param e
+   * is an optional parameter representing the previous exception
+   * in the call stack
+   * @return an instance of ODataJPAModelException which can be then raised.
+   * @throws ODataJPARuntimeException
+   */
+  public static ODataJPAModelException throwException(final MessageReference messageReference, final Throwable e) {
+
+    ODataJPAMessageService messageService;
+    messageService =
+        ODataJPAFactory.createFactory().getODataJPAAccessFactory().getODataJPAMessageService(DEFAULT_LOCALE);
+    String message = messageService.getLocalizedMessage(messageReference, e);
+    return new ODataJPAModelException(message, e, messageReference);
+  }
+
+  private static final long serialVersionUID = 7940106375606950703L;
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/63b621a8/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/exception/ODataJPARuntimeException.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/exception/ODataJPARuntimeException.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/exception/ODataJPARuntimeException.java
new file mode 100644
index 0000000..46737bc
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/exception/ODataJPARuntimeException.java
@@ -0,0 +1,97 @@
+/*******************************************************************************
+ * 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.odata2.jpa.processor.api.exception;
+
+import org.apache.olingo.odata2.api.exception.MessageReference;
+import org.apache.olingo.odata2.jpa.processor.api.factory.ODataJPAFactory;
+
+/**
+ * The exception is thrown for any unexpected errors raising while accessing
+ * data from Java Persistence Models.
+ * 
+ * The exception object is created with localized error texts provided error
+ * texts are maintained in localized languages.
+ * 
+ * 
+ * 
+ */
+public class ODataJPARuntimeException extends ODataJPAException {
+
+  public static final MessageReference ENTITY_MANAGER_NOT_INITIALIZED = createMessageReference(
+      ODataJPARuntimeException.class, "ENTITY_MANAGER_NOT_INITIALIZED");
+  public static final MessageReference RESOURCE_NOT_FOUND = createMessageReference(ODataJPARuntimeException.class,
+      "RESOURCE_NOT_FOUND");
+  public static final MessageReference GENERAL = createMessageReference(ODataJPARuntimeException.class, "GENERAL");
+  public static final MessageReference INNER_EXCEPTION = createMessageReference(ODataJPARuntimeException.class,
+      "INNER_EXCEPTION");
+  public static final MessageReference JOIN_CLAUSE_EXPECTED = createMessageReference(ODataJPARuntimeException.class,
+      "JOIN_CLAUSE_EXPECTED");
+  public static final MessageReference ERROR_JPQLCTXBLDR_CREATE = createMessageReference(
+      ODataJPARuntimeException.class, "ERROR_JPQLCTXBLDR_CREATE");
+  public static final MessageReference ERROR_ODATA_FILTER_CONDITION = createMessageReference(
+      ODataJPARuntimeException.class, "ERROR_ODATA_FILTER_CONDITION");
+  public static final MessageReference ERROR_JPQL_QUERY_CREATE = createMessageReference(ODataJPARuntimeException.class,
+      "ERROR_JPQL_QUERY_CREATE");
+  public static final MessageReference ERROR_JPQL_CREATE_REQUEST = createMessageReference(
+      ODataJPARuntimeException.class, "ERROR_JPQL_CREATE_REQUEST");
+  public static final MessageReference ERROR_JPQL_UPDATE_REQUEST = createMessageReference(
+      ODataJPARuntimeException.class, "ERROR_JPQL_UPDATE_REQUEST");
+  public static final MessageReference ERROR_JPQL_DELETE_REQUEST = createMessageReference(
+      ODataJPARuntimeException.class, "ERROR_JPQL_DELETE_REQUEST");
+  public static final MessageReference ERROR_JPQL_KEY_VALUE = createMessageReference(ODataJPARuntimeException.class,
+      "ERROR_JPQL_KEY_VALUE");
+  public static final MessageReference ERROR_JPQL_PARAM_VALUE = createMessageReference(ODataJPARuntimeException.class,
+      "ERROR_JPQL_PARAM_VALUE");
+  public static final MessageReference ERROR_JPQL_UNIQUE_CONSTRAINT = createMessageReference(
+      ODataJPARuntimeException.class, "ERROR_JPQL_UNIQUE_CONSTRAINT");
+  public static final MessageReference ERROR_JPQL_INTEGRITY_CONSTRAINT = createMessageReference(
+      ODataJPARuntimeException.class, "ERROR_JPQL_INTEGRITY_CONSTRAINT");
+  public static final MessageReference RELATIONSHIP_INVALID = createMessageReference(ODataJPARuntimeException.class,
+      "RELATIONSHIP_INVALID");
+  public static final MessageReference RESOURCE_X_NOT_FOUND = createMessageReference(ODataJPARuntimeException.class,
+      "RESOURCE_X_NOT_FOUND");
+
+  private ODataJPARuntimeException(final String localizedMessage, final Throwable e, final MessageReference msgRef) {
+    super(localizedMessage, e, msgRef);
+  }
+
+  /**
+   * The method creates an exception object of type ODataJPARuntimeException
+   * with localized error texts.
+   * 
+   * @param messageReference
+   * is a <b>mandatory</b> parameter referring to a literal that
+   * could be translated to localized error texts.
+   * @param e
+   * is an optional parameter representing the previous exception
+   * in the call stack
+   * @return an instance of ODataJPARuntimeException which can be then raised.
+   * @throws ODataJPARuntimeException
+   */
+  public static ODataJPARuntimeException throwException(final MessageReference messageReference, final Throwable e) {
+    ODataJPAMessageService messageService;
+    messageService =
+        ODataJPAFactory.createFactory().getODataJPAAccessFactory().getODataJPAMessageService(DEFAULT_LOCALE);
+    String message = messageService.getLocalizedMessage(messageReference, e);
+    return new ODataJPARuntimeException(message, e, messageReference);
+  }
+
+  private static final long serialVersionUID = -5230976355642443012L;
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/63b621a8/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/exception/package-info.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/exception/package-info.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/exception/package-info.java
new file mode 100644
index 0000000..dad4d22
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/exception/package-info.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * 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.
+ ******************************************************************************/
+/**
+ * <h3>OData JPA Processor API Library - Exceptions</h3>
+ * There are two main types of exceptions thrown from the library
+ * <ol><li>Model Exception</li>
+ * <li>Runtime Exception</li></ol>
+ * <br>
+ * The Model Exception is thrown while processing JPA metamodels and
+ * runtime exception is thrown while processing persistence data.
+ * 
+ * 
+ */
+package org.apache.olingo.odata2.jpa.processor.api.exception;
+

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/63b621a8/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/factory/JPAAccessFactory.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/factory/JPAAccessFactory.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/factory/JPAAccessFactory.java
new file mode 100644
index 0000000..20f965e
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/factory/JPAAccessFactory.java
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * 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.odata2.jpa.processor.api.factory;
+
+import org.apache.olingo.odata2.jpa.processor.api.ODataJPAContext;
+import org.apache.olingo.odata2.jpa.processor.api.access.JPAEdmMappingModelAccess;
+import org.apache.olingo.odata2.jpa.processor.api.access.JPAProcessor;
+import org.apache.olingo.odata2.jpa.processor.api.model.JPAEdmModelView;
+
+/**
+ * Factory interface for creating
+ * <ol>
+ * <li>JPA EDM Model view</li>
+ * <li>JPA Processor</li>
+ * </ol>
+ * 
+ * 
+ * 
+ */
+public interface JPAAccessFactory {
+  /**
+   * The method returns an instance of JPA EDM model view based on OData JPA
+   * Context. The JPA EDM model view thus returned can be used for building
+   * EDM models from Java persistence models.
+   * 
+   * @param oDataJPAContext
+   * a non null instance of {@link org.apache.olingo.odata2.jpa.processor.api.ODataJPAContext}
+   * @return an instance of type {@link org.apache.olingo.odata2.jpa.processor.api.model.JPAEdmModelView}
+   */
+  public JPAEdmModelView getJPAEdmModelView(ODataJPAContext oDataJPAContext);
+
+  /**
+   * The method returns an instance of JPA processor based on OData JPA
+   * Context. The JPA Processor thus returned can be used for building and
+   * processing JPQL statements.
+   * 
+   * @param oDataJPAContext
+   * a non null instance of {@link org.apache.olingo.odata2.jpa.processor.api.ODataJPAContext}
+   * @return an instance of type {@link org.apache.olingo.odata2.jpa.processor.api.access.JPAProcessor}
+   */
+  public JPAProcessor getJPAProcessor(ODataJPAContext oDataJPAContext);
+
+  /**
+   * The method returns an instance of JPA EDM mapping model access based on
+   * OData JPA context. The instance thus returned can be used for accessing
+   * the mapping details maintained for an OData service
+   * 
+   * @param oDataJPAContext
+   * a non null instance of {@link org.apache.olingo.odata2.jpa.processor.api.ODataJPAContext}
+   * @return an instance of type {@link org.apache.olingo.odata2.jpa.processor.api.access.JPAEdmMappingModelAccess}
+   */
+  public JPAEdmMappingModelAccess getJPAEdmMappingModelAccess(ODataJPAContext oDataJPAContext);
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/63b621a8/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/factory/JPQLBuilderFactory.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/factory/JPQLBuilderFactory.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/factory/JPQLBuilderFactory.java
new file mode 100644
index 0000000..4880257
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/factory/JPQLBuilderFactory.java
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * 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.odata2.jpa.processor.api.factory;
+
+import org.apache.olingo.odata2.jpa.processor.api.access.JPAMethodContext.JPAMethodContextBuilder;
+import org.apache.olingo.odata2.jpa.processor.api.jpql.JPQLContextType;
+import org.apache.olingo.odata2.jpa.processor.api.jpql.JPQLContextView;
+import org.apache.olingo.odata2.jpa.processor.api.jpql.JPQLContext.JPQLContextBuilder;
+import org.apache.olingo.odata2.jpa.processor.api.jpql.JPQLStatement.JPQLStatementBuilder;
+
+/**
+ * Factory interface for creating following instances
+ * 
+ * <p>
+ * <ul>
+ * <li>JPQL statement builders of type
+ * {@link org.apache.olingo.odata2.jpa.processor.api.jpql.JPQLStatement.JPQLStatementBuilder} </li>
+ * <li>JPQL context builder of type
+ * {@link org.apache.olingo.odata2.jpa.processor.api.jpql.JPQLContext.JPQLContextBuilder} </li>
+ * </ul>
+ * </p>
+ * 
+ * 
+ * @see org.apache.olingo.odata2.jpa.processor.api.factory.ODataJPAFactory
+ */
+public interface JPQLBuilderFactory {
+  /**
+   * The method returns JPQL statement builder for building JPQL statements.
+   * 
+   * @param context
+   * is {@link org.apache.olingo.odata2.jpa.processor.api.jpql.JPQLContext} that determines the type of JPQL statement
+   * builder. The
+   * parameter cannot be null.
+   * @return an instance of JPQLStatementBuilder
+   */
+  public JPQLStatementBuilder getStatementBuilder(JPQLContextView context);
+
+  /**
+   * The method returns a JPQL context builder for building JPQL Context
+   * object.
+   * 
+   * @param contextType
+   * is {@link org.apache.olingo.odata2.jpa.processor.api.jpql.JPQLContextType} that determines the type of JPQL context
+   * builder. The
+   * parameter cannot be null.
+   * @return an instance of JPQLContextBuilder
+   */
+  public JPQLContextBuilder getContextBuilder(JPQLContextType contextType);
+
+  /**
+   * The method returns a JPA method context builder for building JPA Method
+   * context object.
+   * 
+   * @param contextType
+   * is {@link org.apache.olingo.odata2.jpa.processor.api.jpql.JPQLContextType} that determines the type of JPQL context
+   * builder. The
+   * parameter cannot be null.
+   * @return an instance of JPAMethodContextBuilder
+   */
+  public JPAMethodContextBuilder getJPAMethodContextBuilder(JPQLContextType contextType);
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/63b621a8/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/factory/ODataJPAAccessFactory.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/factory/ODataJPAAccessFactory.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/factory/ODataJPAAccessFactory.java
new file mode 100644
index 0000000..50f84f6
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/factory/ODataJPAAccessFactory.java
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ * 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.odata2.jpa.processor.api.factory;
+
+import java.util.Locale;
+
+import org.apache.olingo.odata2.api.edm.provider.EdmProvider;
+import org.apache.olingo.odata2.api.processor.ODataSingleProcessor;
+import org.apache.olingo.odata2.jpa.processor.api.ODataJPAContext;
+import org.apache.olingo.odata2.jpa.processor.api.exception.ODataJPAMessageService;
+
+/**
+ * Factory interface for creating following instances
+ * 
+ * <p>
+ * <ul>
+ * <li>OData JPA Processor of type {@link org.apache.olingo.odata2.api.processor.ODataSingleProcessor}</li>
+ * <li>JPA EDM Provider of type {@link org.apache.olingo.odata2.api.edm.provider.EdmProvider}</li>
+ * <li>OData JPA Context {@link org.apache.olingo.odata2.jpa.processor.api.ODataJPAContext}</li>
+ * </ul>
+ * </p>
+ * 
+ * 
+ * @see org.apache.olingo.odata2.jpa.processor.api.factory.ODataJPAFactory
+ */
+public interface ODataJPAAccessFactory {
+  /**
+   * The method creates an OData JPA Processor. The processor handles runtime
+   * behavior of an OData service.
+   * 
+   * @param oDataJPAContext
+   * an instance of type {@link org.apache.olingo.odata2.jpa.processor.api.ODataJPAContext}.
+   * The context should be initialized properly and cannot be null.
+   * @return An implementation of OData JPA Processor.
+   */
+  public ODataSingleProcessor createODataProcessor(ODataJPAContext oDataJPAContext);
+
+  /**
+   * 
+   * @param oDataJPAContext
+   * an instance of type {@link org.apache.olingo.odata2.jpa.processor.api.ODataJPAContext}.
+   * The context should be initialized properly and cannot be null.
+   * @return An implementation of JPA EdmProvider. EdmProvider handles
+   * meta-data.
+   */
+  public EdmProvider createJPAEdmProvider(ODataJPAContext oDataJPAContext);
+
+  /**
+   * The method creates an instance of OData JPA Context. An empty instance is
+   * returned.
+   * 
+   * @return an instance of type {@link org.apache.olingo.odata2.jpa.processor.api.ODataJPAContext}
+   */
+  public ODataJPAContext createODataJPAContext();
+
+  /**
+   * The method creates an instance of message service for loading language
+   * dependent message text.
+   * 
+   * @param locale
+   * is the language in which the message service should load
+   * message texts.
+   * @return an instance of type {@link org.apache.olingo.odata2.jpa.processor.api.exception.ODataJPAMessageService}
+   */
+  public ODataJPAMessageService getODataJPAMessageService(Locale locale);
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/63b621a8/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/factory/ODataJPAFactory.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/factory/ODataJPAFactory.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/factory/ODataJPAFactory.java
new file mode 100644
index 0000000..77da8c5
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/factory/ODataJPAFactory.java
@@ -0,0 +1,105 @@
+/*******************************************************************************
+ * 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.odata2.jpa.processor.api.factory;
+
+/**
+ * The class is an abstract factory for creating default ODataJPAFactory. The
+ * class's actual implementation is responsible for creating other factory
+ * implementations.The class creates factories implementing interfaces
+ * <ul>
+ * <li>{@link org.apache.olingo.odata2.jpa.processor.api.factory.JPAAccessFactory}</li>
+ * <li>{@link org.apache.olingo.odata2.jpa.processor.api.factory.JPQLBuilderFactory}</li>
+ * <li>{@link org.apache.olingo.odata2.jpa.processor.api.factory.JPQLBuilderFactory}</li>
+ * </ul>
+ * 
+ * <b>Note: </b>Extend this class only if you don't require library's default
+ * factory implementation.
+ * <p>
+ * 
+ * 
+ * 
+ * 
+ * 
+ */
+public abstract class ODataJPAFactory {
+
+  private static final String IMPLEMENTATION =
+      "org.apache.olingo.odata2.jpa.processor.core.factory.ODataJPAFactoryImpl";
+  private static ODataJPAFactory factoryImpl;
+
+  /**
+   * Method creates a factory instance. The instance returned is singleton.
+   * The instance of this factory can be used for creating other factory
+   * implementations.
+   * 
+   * @return instance of type {@link org.apache.olingo.odata2.jpa.processor.api.factory.ODataJPAFactory} .
+   */
+  public static ODataJPAFactory createFactory() {
+
+    if (factoryImpl != null) {
+      return factoryImpl;
+    } else {
+      try {
+        Class<?> clazz = Class.forName(ODataJPAFactory.IMPLEMENTATION);
+
+        Object object = clazz.newInstance();
+        factoryImpl = (ODataJPAFactory) object;
+
+      } catch (Exception e) {
+        throw new RuntimeException(e);
+      }
+
+      return factoryImpl;
+    }
+  }
+
+  /**
+   * The method returns a null reference to JPQL Builder Factory. Override
+   * this method to return an implementation of JPQLBuilderFactory if default
+   * implementation from library is not required.
+   * 
+   * @return instance of type {@link org.apache.olingo.odata2.jpa.processor.api.factory.JPQLBuilderFactory}
+   */
+  public JPQLBuilderFactory getJPQLBuilderFactory() {
+    return null;
+  };
+
+  /**
+   * The method returns a null reference to JPA Access Factory. Override this
+   * method to return an implementation of JPAAccessFactory if default
+   * implementation from library is not required.
+   * 
+   * @return instance of type {@link org.apache.olingo.odata2.jpa.processor.api.factory.JPQLBuilderFactory}
+   */
+  public JPAAccessFactory getJPAAccessFactory() {
+    return null;
+  };
+
+  /**
+   * The method returns a null reference to OData JPA Access Factory. Override
+   * this method to return an implementation of ODataJPAAccessFactory if
+   * default implementation from library is not required.
+   * 
+   * @return instance of type {@link org.apache.olingo.odata2.jpa.processor.api.factory.ODataJPAAccessFactory}
+   */
+  public ODataJPAAccessFactory getODataJPAAccessFactory() {
+    return null;
+  };
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/63b621a8/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/factory/package-info.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/factory/package-info.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/factory/package-info.java
new file mode 100644
index 0000000..d8d3122
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/factory/package-info.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * 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.
+ ******************************************************************************/
+/**
+ * <h3>OData JPA Processor API Library - Factory</h3>
+ * The library provides different types of factories for creating instances for
+ * <ul>
+ * <li>Accessing Java Persistence Model/Data</li>
+ * <li>Building different types of JPQL statements</li>
+ * <li>Accessing OData EDM provider and processor</li>
+ * </ul>
+ * 
+ * The instances of these factories can be obtained from an abstract ODataJPAFactory.
+ * 
+ * 
+ */
+package org.apache.olingo.odata2.jpa.processor.api.factory;
+

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/63b621a8/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/jpql/JPQLContext.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/jpql/JPQLContext.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/jpql/JPQLContext.java
new file mode 100644
index 0000000..0226300
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/jpql/JPQLContext.java
@@ -0,0 +1,204 @@
+/*******************************************************************************
+ * 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.odata2.jpa.processor.api.jpql;
+
+import org.apache.olingo.odata2.jpa.processor.api.exception.ODataJPAModelException;
+import org.apache.olingo.odata2.jpa.processor.api.exception.ODataJPARuntimeException;
+import org.apache.olingo.odata2.jpa.processor.api.factory.ODataJPAFactory;
+
+/**
+ * The abstract class is a compilation of objects required for building
+ * {@link org.apache.olingo.odata2.jpa.processor.api.jpql.JPQLStatement}. Extend this
+ * class to implement specific implementations of JPQL context types (Select,
+ * Join). A JPQL Context is constructed from an OData
+ * request. Depending on OData CRUD operation performed on an Entity, a
+ * corresponding JPQL context object is built. The JPQL context object thus
+ * built can be used for constructing JPQL statements. <br>
+ * A default implementation is provided by the library.
+ * 
+ * 
+ * @see org.apache.olingo.odata2.jpa.processor.api.jpql.JPQLStatement
+ * @see org.apache.olingo.odata2.jpa.processor.api.jpql.JPQLContextType
+ * @see org.apache.olingo.odata2.jpa.processor.api.factory.JPQLBuilderFactory
+ * 
+ */
+public abstract class JPQLContext implements JPQLContextView {
+
+  /**
+   * An alias for Java Persistence Entity
+   */
+  protected String jpaEntityAlias;
+  /**
+   * Java Persistence Entity name
+   */
+  protected String jpaEntityName;
+  /**
+   * The type of JPQL context. Based on the type JPQL statements can be built.
+   */
+  protected JPQLContextType type;
+
+  /**
+   * sets JPA Entity Name into the context
+   * 
+   * @param jpaEntityName
+   * is the name of JPA Entity
+   */
+  protected final void setJPAEntityName(final String jpaEntityName) {
+    this.jpaEntityName = jpaEntityName;
+  }
+
+  /**
+   * sets JPA Entity alias name into the context
+   * 
+   * @param jpaEntityAlias
+   * is the JPA entity alias name
+   */
+  protected final void setJPAEntityAlias(final String jpaEntityAlias) {
+    this.jpaEntityAlias = jpaEntityAlias;
+  }
+
+  /**
+   * gets the JPA entity alias name set into the context
+   */
+  @Override
+  public final String getJPAEntityAlias() {
+    return jpaEntityAlias;
+  }
+
+  /**
+   * sets the JPQL context type into the context
+   * 
+   * @param type
+   * is JPQLContextType
+   */
+  protected final void setType(final JPQLContextType type) {
+    this.type = type;
+  }
+
+  /**
+   * gets the JPA entity name set into the context
+   */
+  @Override
+  public final String getJPAEntityName() {
+    return jpaEntityName;
+  }
+
+  /**
+   * gets the JPQL context type set into the context
+   */
+  @Override
+  public final JPQLContextType getType() {
+    return type;
+  }
+
+  /**
+   * the method returns an instance of type
+   * {@link org.apache.olingo.odata2.jpa.processor.api.jpql.JPQLContext.JPQLContextBuilder} based on the
+   * JPQLContextType. The context builder can be used for
+   * building different JPQL contexts.
+   * 
+   * @param contextType
+   * is the JPQLContextType
+   * @param resultsView
+   * is the OData request view
+   * @return an instance of type {@link org.apache.olingo.odata2.jpa.processor.api.jpql.JPQLContext.JPQLContextBuilder}
+   * @throws ODataJPARuntimeException
+   */
+  public final static JPQLContextBuilder createBuilder(final JPQLContextType contextType, final Object resultsView)
+      throws ODataJPARuntimeException {
+    return JPQLContextBuilder.create(contextType, resultsView);
+  }
+
+  /**
+   * The abstract class is extended by specific JPQLContext builder for
+   * building JPQLContexts.
+   * 
+   * 
+   * 
+   */
+  public static abstract class JPQLContextBuilder {
+    /**
+     * alias counter is an integer counter that is incremented by "1" for
+     * every new alias name generation. The value of counter is used in the
+     * generation of JPA entity alias names.
+     */
+    protected int aliasCounter = 0;
+
+    protected JPQLContextBuilder() {}
+
+    /**
+     * the method instantiates an instance of type JPQLContextBuilder.
+     * 
+     * @param contextType
+     * indicates the type of JPQLContextBuilder to instantiate.
+     * @param resultsView
+     * is the OData request view
+     * @return an instance of type
+     * {@link org.apache.olingo.odata2.jpa.processor.api.jpql.JPQLContext.JPQLContextBuilder}
+     * @throws ODataJPARuntimeException
+     */
+    private static JPQLContextBuilder create(final JPQLContextType contextType, final Object resultsView)
+        throws ODataJPARuntimeException {
+      JPQLContextBuilder contextBuilder =
+          ODataJPAFactory.createFactory().getJPQLBuilderFactory().getContextBuilder(contextType);
+      if (contextBuilder == null) {
+        throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.ERROR_JPQLCTXBLDR_CREATE, null);
+      }
+      contextBuilder.setResultsView(resultsView);
+      return contextBuilder;
+    }
+
+    /**
+     * The abstract method is implemented by specific JPQL context builders
+     * to build JPQL Contexts. The build method makes use of information set
+     * into the context to built JPQL Context Types.
+     * 
+     * @return an instance of {@link org.apache.olingo.odata2.jpa.processor.api.jpql.JPQLContext}
+     * @throws ODataJPAModelException
+     * @throws ODataJPARuntimeException
+     */
+    public abstract JPQLContext build() throws ODataJPAModelException, ODataJPARuntimeException;
+
+    /**
+     * The abstract method is implemented by specific JPQL context builder.
+     * The method sets the OData request view into the JPQL context.
+     * 
+     * @param resultsView
+     * is an instance representing OData request.
+     */
+    protected abstract void setResultsView(Object resultsView);
+
+    /**
+     * The method resets the alias counter value to "0".
+     */
+    protected void resetAliasCounter() {
+      aliasCounter = 0;
+    }
+
+    /**
+     * The method returns a system generated alias name starting with prefix
+     * "E" and ending with suffix "aliasCounter".
+     * 
+     * @return a String representing JPA entity alias name
+     */
+    protected String generateJPAEntityAlias() {
+      return new String("E" + ++aliasCounter);
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/63b621a8/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/jpql/JPQLContextType.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/jpql/JPQLContextType.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/jpql/JPQLContextType.java
new file mode 100644
index 0000000..39d00ac
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/jpql/JPQLContextType.java
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * 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.odata2.jpa.processor.api.jpql;
+
+/**
+ * Enumerated list of JPQL context Types.
+ * 
+ * 
+ * 
+ */
+public enum JPQLContextType {
+  /**
+   * indicates that the JPQL context can be used for building JPQL select
+   * statements
+   */
+  SELECT,
+  /**
+   * indicates that the JPQL context can be used for building JPQL modify
+   * statements
+   */
+  MODIFY,
+  /**
+   * indicates that the JPQL context can be used for building JPQL delete
+   * statements
+   */
+  DELETE,
+  /**
+   * indicates that the JPQL context can be used for building JPQL select
+   * statement that fetches single record
+   */
+  SELECT_SINGLE,
+  /**
+   * indicates that the JPQL context can be used for building JPQL join
+   * statement
+   */
+  JOIN,
+  /**
+   * indicates that the JPQL context can be used for building JPQL join
+   * statement that fetches single record
+   */
+  JOIN_SINGLE,
+  /**
+   * indicates that the JPQL context can be used for building JPQL select
+   * statement that fetches record counts
+   */
+  SELECT_COUNT,
+  /**
+   * indicates that the JPQL context can be used for building JPQL join
+   * statement that fetches single record
+   */
+  JOIN_COUNT,
+  /**
+   * indicates that the JPQL context can be used for building JPA Method
+   * context that can be used for invoking custom functions
+   */
+  FUNCTION
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/63b621a8/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/jpql/JPQLContextView.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/jpql/JPQLContextView.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/jpql/JPQLContextView.java
new file mode 100644
index 0000000..bee9c39
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/jpql/JPQLContextView.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * 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.odata2.jpa.processor.api.jpql;
+
+/**
+ * The interface provides a view on JPQL Context. The view can be used to access
+ * different JPQL context type implementations.
+ * 
+ * 
+ * @see org.apache.olingo.odata2.jpa.processor.api.jpql.JPQLContextType
+ * @see org.apache.olingo.odata2.jpa.processor.api.jpql.JPQLContextType
+ */
+public interface JPQLContextView {
+  /**
+   * The method returns a JPA entity name for which the JPQL context is
+   * relevant.
+   * 
+   * @return JPA entity name
+   */
+  public String getJPAEntityName();
+
+  /**
+   * The method returns a JPA entity alias name for which the JPQL context is
+   * relevant.
+   * 
+   * @return JPA entity alias name
+   */
+
+  public String getJPAEntityAlias();
+
+  /**
+   * The method returns a JPQL context type
+   * 
+   * @return an instance of type {@link org.apache.olingo.odata2.jpa.processor.api.jpql.JPQLContextType}
+   */
+  public JPQLContextType getType();
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/63b621a8/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/jpql/JPQLJoinContextView.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/jpql/JPQLJoinContextView.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/jpql/JPQLJoinContextView.java
new file mode 100644
index 0000000..ec3fe8b
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/jpql/JPQLJoinContextView.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * 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.odata2.jpa.processor.api.jpql;
+
+import java.util.List;
+
+import org.apache.olingo.odata2.jpa.processor.api.access.JPAJoinClause;
+
+/**
+ * The interface provide a view on JPQL Join context.The interface provides
+ * methods for accessing the Join Clause which can be part of JPQL Select
+ * statement. The interface extends the JPQL Select Context to add JQPL Join
+ * clauses to the Select statement. The JPQL Join context view is built from
+ * OData read entity set with navigation request.
+ * 
+ * 
+ * @see org.apache.olingo.odata2.jpa.processor.api.jpql.JPQLSelectContextView
+ * 
+ */
+public interface JPQLJoinContextView extends JPQLSelectContextView {
+  /**
+   * The method returns a list of JPA Join Clauses. The returned list of
+   * values can be used for building JPQL Statements with Join clauses.
+   * 
+   * @return a list of {@link org.apache.olingo.odata2.jpa.processor.api.access.JPAJoinClause}
+   */
+  public List<JPAJoinClause> getJPAJoinClauses();
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/63b621a8/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/jpql/JPQLJoinSelectSingleContextView.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/jpql/JPQLJoinSelectSingleContextView.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/jpql/JPQLJoinSelectSingleContextView.java
new file mode 100644
index 0000000..2fa8c3c
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/jpql/JPQLJoinSelectSingleContextView.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * 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.odata2.jpa.processor.api.jpql;
+
+import java.util.List;
+
+import org.apache.olingo.odata2.jpa.processor.api.access.JPAJoinClause;
+
+/**
+ * The interface provide a view on JPQL Join Clauses.The interface is an
+ * extension to JPQL select single context and provides methods for accessing
+ * JPQL Join clauses. The view can be used for building JPQL statements without
+ * any WHERE,ORDERBY clauses. The clauses are built from OData read entity
+ * request views.
+ * 
+ * 
+ * @see org.apache.olingo.odata2.jpa.processor.api.jpql.JPQLSelectSingleContextView
+ * 
+ */
+public interface JPQLJoinSelectSingleContextView extends JPQLSelectSingleContextView {
+
+  /**
+   * The method returns a list of JPA Join Clauses. The returned list of
+   * values can be used for building JPQL Statements with Join clauses.
+   * 
+   * @return a list of {@link org.apache.olingo.odata2.jpa.processor.api.access.JPAJoinClause}
+   */
+  public abstract List<JPAJoinClause> getJPAJoinClauses();
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/63b621a8/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/jpql/JPQLSelectContextView.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/jpql/JPQLSelectContextView.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/jpql/JPQLSelectContextView.java
new file mode 100644
index 0000000..88878b6
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/jpql/JPQLSelectContextView.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * 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.odata2.jpa.processor.api.jpql;
+
+import java.util.HashMap;
+
+/**
+ * The interface provide a view on JPQL select context.The interface provides
+ * methods for accessing the clauses of a JPQL SELECT statement like "SELECT",
+ * "ORDERBY", "WHERE". The clauses are built from OData read entity set request
+ * views. The clauses thus built can be used for building JPQL Statements.
+ * 
+ * 
+ * @see org.apache.olingo.odata2.jpa.processor.api.jpql.JPQLStatement
+ * 
+ */
+public interface JPQLSelectContextView extends JPQLContextView {
+  /**
+   * The method returns a JPQL SELECT clause. The SELECT clause is built from
+   * $select OData system Query option.
+   * 
+   * @return a String representing a SELECT clause in JPQL
+   */
+  public String getSelectExpression();
+
+  /**
+   * The method returns a Hash Map of JPQL ORDERBY clause. The ORDERBY clause
+   * is built from $orderby OData system query option. The hash map contains
+   * <ol>
+   * <li>Key - JPA Entity Property name to be ordered</li>
+   * <li>Value - Sort Order in JPQL (desc,asc)</li>
+   * </ol>
+   * 
+   * @return a hash map of (JPA Property Name,Sort Order)
+   */
+  public HashMap<String, String> getOrderByCollection();
+
+  /**
+   * The method returns a JPQL WHERE condition as string. The WHERE condition
+   * can be built from $filter OData System Query Option and/or Key predicates
+   * of an OData Request.
+   * 
+   * @return a String representing a WHERE condition in JPQL
+   */
+  public String getWhereExpression();
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/63b621a8/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/jpql/JPQLSelectSingleContextView.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/jpql/JPQLSelectSingleContextView.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/jpql/JPQLSelectSingleContextView.java
new file mode 100644
index 0000000..2a4ca0c
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/jpql/JPQLSelectSingleContextView.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * 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.odata2.jpa.processor.api.jpql;
+
+import java.util.List;
+
+import org.apache.olingo.odata2.api.uri.KeyPredicate;
+
+/**
+ * The interface provide a view on JPQL select single context.The interface
+ * provides methods for accessing the clause of a JPQL SELECT statement like
+ * "SELECT". The view can be used for building JPQL statements without any
+ * WHERE,JOIN,ORDERBY clauses. The clauses are built from OData read entity
+ * request views.
+ * 
+ * 
+ * @see org.apache.olingo.odata2.jpa.processor.api.jpql.JPQLStatement
+ * 
+ */
+public interface JPQLSelectSingleContextView extends JPQLContextView {
+  /**
+   * The method returns a JPQL SELECT clause. The SELECT clause is built from
+   * $select OData system Query option.
+   * 
+   * @return a String representing a SELECT clause in JPQL
+   */
+  public String getSelectExpression();
+
+  /**
+   * The method returns the list of key predicates that can be used for
+   * constructing the WHERE clause in JPQL statements. The OData entity key
+   * predicates are thus converted into JPA entity keys.
+   * 
+   * @return a list of key predicates
+   */
+  public List<KeyPredicate> getKeyPredicates();
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/63b621a8/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/jpql/JPQLStatement.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/jpql/JPQLStatement.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/jpql/JPQLStatement.java
new file mode 100644
index 0000000..56ea231
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/jpql/JPQLStatement.java
@@ -0,0 +1,148 @@
+/*******************************************************************************
+ * 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.odata2.jpa.processor.api.jpql;
+
+import org.apache.olingo.odata2.jpa.processor.api.exception.ODataJPARuntimeException;
+import org.apache.olingo.odata2.jpa.processor.api.factory.ODataJPAFactory;
+
+/**
+ * The class represents a Java Persistence Query Language (JPQL) Statement.
+ * The JPQL statement is built using a builder namely
+ * {@link org.apache.olingo.odata2.jpa.processor.api.jpql.JPQLStatement.JPQLStatementBuilder} . Based upon the JPQL
+ * Context types ( {@link org.apache.olingo.odata2.jpa.processor.api.jpql.JPQLContextType} different
+ * kinds of JPQL statements are built.
+ * The JPQL statements thus generated can be executed using JPA Query APIs to fetch JPA entities.
+ * 
+ * 
+ * @see org.apache.olingo.odata2.jpa.processor.api.factory.JPQLBuilderFactory
+ * @see org.apache.olingo.odata2.jpa.processor.api.jpql.JPQLContextView
+ */
+public class JPQLStatement {
+
+  protected String statement;
+
+  /**
+   * The method is used for creating an instance of JPQL Statement Builder for
+   * building JPQL statements. The JPQL Statement builder is created based
+   * upon the JPQL Context.
+   * 
+   * @param context
+   * a non null value of {@link org.apache.olingo.odata2.jpa.processor.api.jpql.JPQLContextView} . The context is
+   * expected to be set to be built with no
+   * errors.
+   * @return an instance of JPQL statement builder
+   * @throws ODataJPARuntimeException
+   */
+  public static JPQLStatementBuilder createBuilder(final JPQLContextView context) throws ODataJPARuntimeException {
+    return JPQLStatementBuilder.create(context);
+  }
+
+  private JPQLStatement(final String statement) {
+    this.statement = statement;
+  }
+
+  /**
+   * The method provides a String representation of JPQLStatement.
+   */
+  @Override
+  public String toString() {
+    return statement;
+  }
+
+  /**
+   * The abstract class is extended by specific JPQL statement builders for
+   * building JPQL statements like
+   * <ol>
+   * <li>Select statements</li>
+   * <li>Select single statements</li>
+   * <li>Select statements with Join</li>
+   * <li>Insert/Modify/Delete statements</li>
+   * </ol>
+   * 
+   * A default statement builder for building each kind of JPQL statements is
+   * provided by the library.
+   * 
+   * 
+   * 
+   */
+  public static abstract class JPQLStatementBuilder {
+
+    protected JPQLStatementBuilder() {}
+
+    private static final JPQLStatementBuilder create(final JPQLContextView context) throws ODataJPARuntimeException {
+      return ODataJPAFactory.createFactory().getJPQLBuilderFactory().getStatementBuilder(context);
+    }
+
+    protected final JPQLStatement createStatement(final String statement) {
+      return new JPQLStatement(statement);
+    }
+
+    /**
+     * The abstract method is implemented by specific statement builder for
+     * building JPQL Statement.
+     * 
+     * @return an instance of {@link org.apache.olingo.odata2.jpa.processor.api.jpql.JPQLStatement}
+     * @throws ODataJPARuntimeException
+     * in case there are errors building the statements
+     */
+    public abstract JPQLStatement build() throws ODataJPARuntimeException;
+
+  }
+
+  public static final class Operator {
+    public static final String EQ = "=";
+    public static final String NE = "<>";
+    public static final String LT = "<";
+    public static final String LE = "<=";
+    public static final String GT = ">";
+    public static final String GE = ">=";
+    public static final String AND = "AND";
+    public static final String NOT = "NOT";
+    public static final String OR = "OR";
+
+  }
+
+  public static final class KEYWORD {
+    public static final String SELECT = "SELECT";
+    public static final String FROM = "FROM";
+    public static final String WHERE = "WHERE";
+    public static final String LEFT_OUTER_JOIN = "LEFT OUTER JOIN";
+    public static final String OUTER = "OUTER";
+    public static final String JOIN = "JOIN";
+    public static final String ORDERBY = "ORDER BY";
+    public static final String COUNT = "COUNT";
+    public static final String OFFSET = ".000";
+    public static final String TIMESTAMP = "ts";
+
+  }
+
+  public static final class DELIMITER {
+    public static final char SPACE = ' ';
+    public static final char COMMA = ',';
+    public static final char PERIOD = '.';
+    public static final char PARENTHESIS_LEFT = '(';
+    public static final char PARENTHESIS_RIGHT = ')';
+    public static final char COLON = ':';
+    public static final char HYPHEN = '-';
+    public static final char LEFT_BRACE = '{';
+    public static final char RIGHT_BRACE = '}';
+    public static final char LONG = 'L';
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/63b621a8/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/jpql/package-info.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/jpql/package-info.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/jpql/package-info.java
new file mode 100644
index 0000000..c059f7e
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/jpql/package-info.java
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * 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.
+ ******************************************************************************/
+/**
+ * <h3>OData JPA Processor API Library - Java Persistence Query Language</h3>
+ * The library provides set of APIs for building JPQL contexts from OData Requests.
+ * The JPQL contexts thus built can be used for building JPQL Statements.
+ * 
+ * 
+ */
+package org.apache.olingo.odata2.jpa.processor.api.jpql;
+

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/63b621a8/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/model/JPAEdmAssociationEndView.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/model/JPAEdmAssociationEndView.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/model/JPAEdmAssociationEndView.java
new file mode 100644
index 0000000..2d1262e
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/model/JPAEdmAssociationEndView.java
@@ -0,0 +1,91 @@
+/*******************************************************************************
+ * 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.odata2.jpa.processor.api.model;
+
+import org.apache.olingo.odata2.api.edm.provider.AssociationEnd;
+
+/**
+ * <p>
+ * A view on Java Persistence Entity Relationship and Entity Data Model
+ * Association End.
+ * </p>
+ * <p>
+ * The implementation of the view provides access to EDM Association Ends
+ * created from Java Persistence Entity Relationships. The implementation acts
+ * as a container for Association Ends.
+ * </p>
+ * 
+ * @org.apache.olingo.odata2.DoNotImplement
+ * @see org.apache.olingo.odata2.jpa.processor.api.model.JPAEdmAssociationView
+ * 
+ */
+public interface JPAEdmAssociationEndView extends JPAEdmBaseView {
+
+  /**
+   * The method gets the one of the association ends present in the container.
+   * 
+   * @return one of the {@link org.apache.olingo.odata2.api.edm.provider.AssociationEnd} for an
+   * {@link org.apache.olingo.odata2.api.edm.provider.Association}
+   */
+  AssociationEnd getEdmAssociationEnd2();
+
+  /**
+   * The method gets the other association end present in the container.
+   * 
+   * @return one of the {@link org.apache.olingo.odata2.api.edm.provider.AssociationEnd} for an
+   * {@link org.apache.olingo.odata2.api.edm.provider.Association}
+   */
+  AssociationEnd getEdmAssociationEnd1();
+
+  /**
+   * The method compares two ends {<b>end1, end2</b>} of an
+   * {@link org.apache.olingo.odata2.api.edm.provider.AssociationEnd} against its
+   * two ends.
+   * 
+   * The Method compares the following properties in each end for equality <i>
+   * <ul>
+   * <li>{@link org.apache.olingo.odata2.api.edm.FullQualifiedName} of End Type</li>
+   * <li>{@link org.apache.olingo.odata2.api.edm.EdmMultiplicity} of End</li>
+   * </ul>
+   * </i>
+   * 
+   * @param end1
+   * one end of type {@link org.apache.olingo.odata2.api.edm.provider.AssociationEnd} of
+   * an {@link org.apache.olingo.odata2.api.edm.provider.Association}
+   * @param end2
+   * other end of type {@link org.apache.olingo.odata2.api.edm.provider.AssociationEnd} of
+   * an {@link org.apache.olingo.odata2.api.edm.provider.Association} <p>
+   * @return <ul>
+   * <li><i>true</i> - Only if the properties of <b>end1</b> matches
+   * with all the properties of any one end and only if the properties
+   * of <b>end2</b> matches with all the properties of the remaining
+   * end</li> <li><i>false</i> - Otherwise</li>
+   * </ul>
+   */
+  boolean compare(AssociationEnd end1, AssociationEnd end2);
+
+  String getJoinColumnName();
+
+  String getJoinColumnReferenceColumnName();
+
+  String getMappedByName();
+
+  String getOwningPropertyName();
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/63b621a8/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/model/JPAEdmAssociationSetView.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/model/JPAEdmAssociationSetView.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/model/JPAEdmAssociationSetView.java
new file mode 100644
index 0000000..e0ed0db
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/model/JPAEdmAssociationSetView.java
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * 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.odata2.jpa.processor.api.model;
+
+import java.util.List;
+
+import org.apache.olingo.odata2.api.edm.provider.Association;
+import org.apache.olingo.odata2.api.edm.provider.AssociationSet;
+
+/**
+ * <p>
+ * A view on Java Persistence Entity Relationship and Entity Data Model
+ * Association Set.
+ * </p>
+ * <p>
+ * The implementation of the view provides access to EDM Association Set created
+ * from Java Persistence Entity Relationship. The implementation act as a
+ * container for list of association sets that are consistent.
+ * </p>
+ * 
+ * 
+ * <p>
+ * @org.apache.olingo.odata2.DoNotImplement
+ * @see org.apache.olingo.odata2.jpa.processor.api.model.JPAEdmAssociationView
+ */
+public interface JPAEdmAssociationSetView extends JPAEdmBaseView {
+
+  /**
+   * The method returns a consistent list of association sets. An association
+   * set is set to be consistent only if all its mandatory properties can be
+   * completely built from a Java Persistence Relationship.
+   * 
+   * @return a consistent list of {@link org.apache.olingo.odata2.api.edm.provider.AssociationSet}
+   * 
+   */
+  List<AssociationSet> getConsistentEdmAssociationSetList();
+
+  /**
+   * The method returns an association set that is currently being processed.
+   * 
+   * @return an instance of type {@link org.apache.olingo.odata2.api.edm.provider.AssociationSet}
+   */
+  AssociationSet getEdmAssociationSet();
+
+  /**
+   * The method returns an association from which the association set is
+   * currently being processed.
+   * 
+   * @return an instance of type {@link org.apache.olingo.odata2.api.edm.provider.Association}
+   */
+  Association getEdmAssociation();
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/63b621a8/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/model/JPAEdmAssociationView.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/model/JPAEdmAssociationView.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/model/JPAEdmAssociationView.java
new file mode 100644
index 0000000..ad29cc0
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/model/JPAEdmAssociationView.java
@@ -0,0 +1,128 @@
+/*******************************************************************************
+ * 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.odata2.jpa.processor.api.model;
+
+import java.util.List;
+
+import org.apache.olingo.odata2.api.edm.provider.Association;
+
+/**
+ * <p>
+ * A View on Java Persistence Entity Relationship and Entity Data Model
+ * Association.
+ * </p>
+ * <p>
+ * The implementation of the view provides access to EDM Association created
+ * from Java Persistence Entity Relationships. The implementation acts as a
+ * container for list of association that are consistent.
+ * 
+ * An Association is said to be consistent only
+ * <ol>
+ * <li>If both the Ends of Association are consistent</li>
+ * <li>If referential constraint exists for the Association then it should be
+ * consistent</li>
+ * </ol>
+ * </p>
+ * 
+ * 
+ * <p>
+ * @org.apache.olingo.odata2.DoNotImplement
+ * @see org.apache.olingo.odata2.jpa.processor.api.model.JPAEdmAssociationSetView
+ * @see org.apache.olingo.odata2.jpa.processor.api.model.JPAEdmReferentialConstraintView
+ * 
+ */
+public interface JPAEdmAssociationView extends JPAEdmBaseView {
+
+  /**
+   * The method returns an association which is currently being processed.
+   * 
+   * @return an {@link org.apache.olingo.odata2.api.edm.provider.Association}
+   */
+  public Association getEdmAssociation();
+
+  /**
+   * The method returns a consistent list of associations. An association is
+   * set to be consistent only if all its mandatory properties can be
+   * completely built from a Java Persistence Relationship.
+   * 
+   * @return a consistent list of {@link org.apache.olingo.odata2.api.edm.provider.Association}
+   * 
+   */
+  public List<Association> getConsistentEdmAssociationList();
+
+  /**
+   * The method adds {@link org.apache.olingo.odata2.jpa.processor.api.model.JPAEdmAssociationView} to its container
+   * 
+   * @param associationView
+   * of type {@link org.apache.olingo.odata2.jpa.processor.api.model.JPAEdmAssociationView}
+   */
+  public void addJPAEdmAssociationView(JPAEdmAssociationView associationView,
+      JPAEdmAssociationEndView associationEndView);
+
+  /**
+   * The method searches for an Association in its container against the
+   * search parameter <b>view</b> of type {@link org.apache.olingo.odata2.jpa.processor.api.model.JPAEdmAssociationView}
+   * .
+   * 
+   * The Association in the container <b>view</b> is searched against the
+   * consistent list of Association stored in this container.
+   * 
+   * @param view
+   * of type {@link org.apache.olingo.odata2.jpa.processor.api.model.JPAEdmAssociationView}
+   * @return {@link org.apache.olingo.odata2.api.edm.provider.Association} if found
+   * in the container
+   */
+  public Association searchAssociation(JPAEdmAssociationEndView view);
+
+  /**
+   * The method adds the referential constraint view to its container.
+   * <p>
+   * <b>Note: </b>The referential constraint view is added only if it exists.
+   * </p>
+   * 
+   * @param refView
+   * of type {@link org.apache.olingo.odata2.jpa.processor.api.model.JPAEdmReferentialConstraintView}
+   */
+  public void addJPAEdmRefConstraintView(JPAEdmReferentialConstraintView refView);
+
+  /**
+   * The method returns the referential constraint view that is currently
+   * being processed.
+   * 
+   * @return an instance of type
+   * {@link org.apache.olingo.odata2.jpa.processor.api.model.JPAEdmReferentialConstraintView}
+   */
+  public JPAEdmReferentialConstraintView getJPAEdmReferentialConstraintView();
+
+  /**
+   * The method searches for the number of associations with similar endpoints in its container against the
+   * search parameter <b>view</b> of type {@link org.apache.olingo.odata2.jpa.processor.api.model.JPAEdmAssociationView}
+   * .
+   * 
+   * The Association in the container <b>view</b> is searched against the
+   * consistent list of Association stored in this container.
+   * 
+   * @param view
+   * of type {@link org.apache.olingo.odata2.jpa.processor.api.model.JPAEdmAssociationView}
+   * @return {@link org.apache.olingo.odata2.api.edm.provider.Association} if found
+   * in the container
+   */
+  int getNumberOfAssociationsWithSimilarEndPoints(JPAEdmAssociationEndView view);
+
+}