Johannes Hoenger created OLINGO-824:
---------------------------------------
Summary: nullable references
Key: OLINGO-824
URL: https://issues.apache.org/jira/browse/OLINGO-824
Project: Olingo
Issue Type: Bug
Components: odata2-jpa
Affects Versions: V2 2.0.5
Reporter: Johannes Hoenger
I recognised a potential bug in the JPA processor. I have an entity with the
following structure:
{code:title=A.java}
public class A {
@Id
@Column(name = "ID", nullable = false)
private String id;
@ManyToOne(optional = true)
@JoinColumn(name = "PARENT_ID", referencedColumnName = "ID" , nullable =
true)
private A parent;
}
{code}
Notice the self reference from "parent" to "id". While the *"id" field can not
be set null* the field *"parent" is nullable*. In the JPA context, this
definition can be interpreted.
Lets have a look at the following entity instances:
||ID||PARENT||
|1|null|
|2|1|
While the serialization of Olingo works perfectly fine for the instance with id
2, it fails for the instance with id 1. An EdmSimpleTypeException is thrown and
the following error is returned:
{code:javascript}
{
"error": {
"code": null,
"message": {
"lang": "en",
"value": "An exception of type 'EdmSimpleTypeException' occurred."
}
}
}
{code}
A closer look into the sources (see attached screenshot) seems to indicate that
the "nullable" attribute for the field "parent" is retrieved from the
referenced field "id" instead of "parent" itself.
I also noticed that this issue does not arise, if nullable attribute of the
"id" field is set to true.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)