Bug 411153 - JPA-RS: Different element name is used in namedQueryUpdate response for JSON and XML
Summary: JPA-RS: Different element name is used in namedQueryUpdate response for JSON ...
Status: NEW
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: 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-06-19 13:31 EDT by Gul Onural CLA
Modified: 2022-06-09 10:21 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Gul Onural CLA 2013-06-19 13:31:51 EDT
There is an inconsistency between xml and json responses for the namedQueryUpdate API. The namedQueryUpdate returns number of records impacted  from the update. The JPA-RS wraps this Integer value in a JAXBElement as :

JAXBElement jaxbElement = new JAXBElement(new QName("result"), Integer.class, result);

The marshaller used to marshall JPA-RS responses has MarshallerProperties.JSON_INCLUDE_ROOT set to false. This causes MOXy to disregard the JAXB Element for JSON, and then it will use "value" because it needs a key (default is "value").

As a result, the XML output will look like 

<result>25</result>

while JSON output is :

{"value": 25}

The solution is to set the JSON_INCLUDE_ROOT to true for that particular API, so that the output of XML and JSON would consistently use "result".
Comment 1 Tom Ware CLA 2013-07-11 15:09:18 EDT
Setting target and priority.  See the following page for the meanings of these fields:

http://wiki.eclipse.org/EclipseLink/Development/Bugs/Guidelines

Community: Please vote for this bug if it is important to you.  Votes are one of the main criteria we use to determine which bugs to fix next.
Comment 2 Eclipse Webmaster CLA 2022-06-09 10:21:26 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink