olingo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m...@apache.org
Subject [23/33] olingo-odata2 git commit: [OLINGO-481] Support JPA Relations inherited from Super Class
Date Wed, 10 Dec 2014 19:31:12 GMT
[OLINGO-481] Support JPA Relations inherited from Super Class


Signed-off-by: Chandan V A <chandan.v.a@sap.com>

Project: http://git-wip-us.apache.org/repos/asf/olingo-odata2/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata2/commit/847df0f2
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata2/tree/847df0f2
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata2/diff/847df0f2

Branch: refs/heads/Olingo-129_PocJpaDataStore
Commit: 847df0f2647c83773432e25dedfc7922e79425db
Parents: 0c4bac5
Author: Chandan V A <chandan.v.a@sap.com>
Authored: Sun Nov 23 13:01:18 2014 +0530
Committer: Chandan V A <chandan.v.a@sap.com>
Committed: Sun Nov 23 13:01:18 2014 +0530

----------------------------------------------------------------------
 .../core/access/data/JPAEntityParser.java       |  2 +-
 .../jpa/processor/ref/model/Customer.java       | 39 ++++++++++++-------
 .../jpa/processor/ref/model/CustomerBase.java   | 40 ++++++++++++++++++++
 3 files changed, 66 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/847df0f2/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/access/data/JPAEntityParser.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/access/data/JPAEntityParser.java
b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/access/data/JPAEntityParser.java
index 693d91f..7f4eed6 100644
--- a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/access/data/JPAEntityParser.java
+++ b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/access/data/JPAEntityParser.java
@@ -174,7 +174,7 @@ public final class JPAEntityParser {
           methodName = getAccessModifierName(navigationProperty.getName(),
               navigationProperty.getMapping(), ACCESS_MODIFIER_GET);
           Method getterMethod = jpaEntity.getClass()
-              .getDeclaredMethod(methodName, (Class<?>[]) null);
+              .getMethod(methodName, (Class<?>[]) null);
           getterMethod.setAccessible(true);
           result = getPropertyValue(getterMethod, jpaEntity);
           navigationMap.put(navigationProperty.getName(), result);

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/847df0f2/odata2-jpa-processor/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/Customer.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/Customer.java
b/odata2-jpa-processor/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/Customer.java
index 6dabd2a..12e38ac 100644
--- a/odata2-jpa-processor/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/Customer.java
+++ b/odata2-jpa-processor/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/Customer.java
@@ -19,20 +19,19 @@
 package org.apache.olingo.odata2.jpa.processor.ref.model;
 
 import java.sql.Timestamp;
-import java.util.ArrayList;
-import java.util.List;
 
-import javax.persistence.CascadeType;
 import javax.persistence.Column;
 import javax.persistence.Embedded;
 import javax.persistence.Entity;
+import javax.persistence.FetchType;
 import javax.persistence.Id;
-import javax.persistence.OneToMany;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
 import javax.persistence.Table;
 
 @Entity
 @Table(name = "T_CUSTOMER")
-public class Customer {
+public class Customer extends CustomerBase {
 
   @Id
   @Column(name = "ID")
@@ -47,9 +46,21 @@ public class Customer {
   @Column(name = "CREATED_AT")
   private Timestamp createdAt;
 
-  @OneToMany(mappedBy = "customer", cascade = CascadeType.ALL)
-  private List<SalesOrderHeader> orders = new ArrayList<SalesOrderHeader>();
+  public Customer getInternal() {
+    return internal;
+  }
+
+  public void setInternal(Customer internal) {
+    this.internal = internal;
+  }
 
+//  @OneToMany(mappedBy = "customer", cascade = CascadeType.ALL)
+//  private List<SalesOrderHeader> orders = new ArrayList<SalesOrderHeader>();
+  
+  @ManyToOne(fetch=FetchType.LAZY)
+  @JoinColumn(name="internal_id", referencedColumnName="ID")
+  private Customer internal;
+  
   public Long getId() {
     return id;
   }
@@ -66,13 +77,13 @@ public class Customer {
     this.name = name;
   }
 
-  public List<SalesOrderHeader> getOrders() {
-    return orders;
-  }
-
-  public void setOrders(final List<SalesOrderHeader> orders) {
-    this.orders = orders;
-  }
+//  public List<SalesOrderHeader> getOrders() {
+//    return orders;
+//  }
+//
+//  public void setOrders(final List<SalesOrderHeader> orders) {
+//    this.orders = orders;
+//  }
 
   public Address getAddress() {
     return address;

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/847df0f2/odata2-jpa-processor/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/CustomerBase.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/CustomerBase.java
b/odata2-jpa-processor/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/CustomerBase.java
new file mode 100644
index 0000000..f740c59
--- /dev/null
+++ b/odata2-jpa-processor/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/CustomerBase.java
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * 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.ref.model;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.persistence.CascadeType;
+import javax.persistence.MappedSuperclass;
+import javax.persistence.OneToMany;
+
+@MappedSuperclass
+public class CustomerBase {
+  @OneToMany(mappedBy = "customer", cascade = CascadeType.ALL)
+  private List<SalesOrderHeader> orders = new ArrayList<SalesOrderHeader>();
+
+  public List<SalesOrderHeader> getOrders() {
+    return orders;
+  }
+
+  public void setOrders(final List<SalesOrderHeader> orders) {
+    this.orders = orders;
+  }
+}


Mime
View raw message