Bug 402394 - JPA-RS: Don't generate _relationships property in JSON when empty
Summary: JPA-RS: Don't generate _relationships property in JSON when empty
Status: NEW
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: Macintosh Mac OS X
: P2 normal (vote)
Target Milestone: ---   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact:
URL:
Whiteboard: jpa-rs
Keywords:
Depends on:
Blocks:
 
Reported: 2013-03-04 17:57 EST by Shaun Smith CLA
Modified: 2022-06-09 10:19 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Shaun Smith CLA 2013-03-04 17:57:43 EST
Structure of XML and JSON entities are inconsistent.  When an entity has no relationships the generated XML does not include an empty element while an empty array is generated in JSON.  An entity with no relationships should not generate a "_relationships" attribute.

<employee>
   <addressId>0</addressId>
   <firstName>Shaun</firstName>
   <id>3</id>
   <lastName>Smith</lastName>
</employee>

{
  "addressId": 0,
  "firstName": "Shaun",
  "id": 3,
  "lastName": "Smith",
  "_relationships": []
}
Comment 1 Tom Ware CLA 2013-03-05 08:04:28 EST
Are you referring to an entity that has no relationship mappings, or an entity that has relationships mappings but they are all empty?
Comment 2 Shaun Smith CLA 2013-03-05 17:05:52 EST
I mean an Entity with no relationship mappings. E.g. the following class with mappings in orm.xml:

public class Employee implements Serializable {
	private static final long serialVersionUID = -4158718142583269181L;

	private int id;
	private String firstName;
	private String lastName;
	private int addressId;

will produce the JSON and XML in the first comment.  The "_relationships" property is out of place given there are no relationships mapped. And XML is ok.
Comment 3 Eclipse Webmaster CLA 2022-06-09 10:19:49 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink