‎2014 Oct 24 11:41 AM
Hello everyone,
I implemented an OData Service which is consumed by SAPUI5 on the frontend using Apache Olingo. That service works perfectly fine, as long as there is no ManyToOne-Relation in a JAP Entity. I access the Classiccars Derby Database of MyEclipse to test things out. Customers-Entity is ok, everything works fine with OData, because this Entity has an OneToMany Relation with Payments.
If I know want to access the Payment entity via OData (ManyToOne -> Customer) I get an SimpleTypeException:
"org.apache.olingo.odata2.api.edm.EdmSimpleTypeException",
"The type 'class org.globus.de.odataservice.data.dataobjects.Customer' of the value object is not supported."
That is not wrong, I know that my Customer Class is not an EdmSimepleType, therefore the Exception might be correct. But when I remove the relation in the Entity and try to access the data again, the same error comes for double, String, integer, no matter what type - I always get an EdmSimpleTypeException. Something is clearly going wrong here - this only occurs with ManyToOne-Releations.
Is there something I am missing in the Entity?
Here the code:
Payment-Entity
/**
* The persistent class for the PAYMENT database table.
*
*/
@Entity
public class Payment implements Serializable {
private static final long serialVersionUID = 1L;
@EmbeddedId
private PaymentPK id;
private double amount;
private String paymentdate;
//bi-directional many-to-one association to Customer
@ManyToOne
@JoinColumn(name="CUSTOMERNUMBER")
private Customer customer;
public Payment() {
}
public PaymentPK getId() {
return this.id;
}
public void setId(PaymentPK id) {
this.id = id;
}
public double getAmount() {
return this.amount;
}
public void setAmount(double amount) {
this.amount = amount;
}
public String getPaymentdate() {
return this.paymentdate;
}
public void setPaymentdate(String paymentdate) {
this.paymentdate = paymentdate;
}
public Customer getCustomer() {
return this.customer;
}
public void setCustomer(Customer customer) {
this.customer = customer;
}
}
Related Customer Entity
/**
* The persistent class for the CUSTOMER database table.
*
*/
@Entity
public class Customer implements Serializable {
private static final long serialVersionUID = 1L;
@Id
private int customernumber;
private String addressline1;
private String addressline2;
private String city;
private String contactfirstname;
private String contactlastname;
private String country;
private double creditlimit;
private String customername;
private String phone;
private String postalcode;
private int salesrepemployeenumber;
private String state;
//bi-directional many-to-one association to Payment
@OneToMany(mappedBy="customer")
private List<Payment> payments;
public Customer() {
}
public int getCustomernumber() {
return this.customernumber;
}
public void setCustomernumber(int customernumber) {
this.customernumber = customernumber;
}
public String getAddressline1() {
return this.addressline1;
}
public void setAddressline1(String addressline1) {
this.addressline1 = addressline1;
}
public String getAddressline2() {
return this.addressline2;
}
public void setAddressline2(String addressline2) {
this.addressline2 = addressline2;
}
public String getCity() {
return this.city;
}
public void setCity(String city) {
this.city = city;
}
public String getContactfirstname() {
return this.contactfirstname;
}
public void setContactfirstname(String contactfirstname) {
this.contactfirstname = contactfirstname;
}
public String getContactlastname() {
return this.contactlastname;
}
public void setContactlastname(String contactlastname) {
this.contactlastname = contactlastname;
}
public String getCountry() {
return this.country;
}
public void setCountry(String country) {
this.country = country;
}
public double getCreditlimit() {
return this.creditlimit;
}
public void setCreditlimit(double creditlimit) {
this.creditlimit = creditlimit;
}
public String getCustomername() {
return this.customername;
}
public void setCustomername(String customername) {
this.customername = customername;
}
public String getPhone() {
return this.phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public String getPostalcode() {
return this.postalcode;
}
public void setPostalcode(String postalcode) {
this.postalcode = postalcode;
}
public int getSalesrepemployeenumber() {
return this.salesrepemployeenumber;
}
public void setSalesrepemployeenumber(int salesrepemployeenumber) {
this.salesrepemployeenumber = salesrepemployeenumber;
}
public String getState() {
return this.state;
}
public void setState(String state) {
this.state = state;
}
public List<Payment> getPayments() {
return this.payments;
}
public void setPayments(List<Payment> payments) {
this.payments = payments;
}
}
Sorry, highlighting is not working properly..
‎2015 Feb 09 9:20 AM
Hi Tobias,
is this still an actual issue for you?
If yes, you could create an issue at official Olingo JIRA (https://issues.apache.org/jira/browse/OLINGO) for this.
But before you create an issue it would be nice if you could check whether this issue still exists in newest (2.0.2) version of Olingo.
Kind regards,
Michael
‎2015 Feb 09 2:16 PM