Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 334987

Summary: JPA getSingleResult of a scalar native query return different classes
Product: z_Archived Reporter: Ivan Belis <ivan.belis>
Component: EclipselinkAssignee: Nobody - feel free to take it <nobody>
Status: CLOSED FIXED QA Contact:
Severity: minor    
Priority: P3 CC: rick.sapir, tom.ware
Version: unspecifiedKeywords: Documentation
Target Milestone: ---Flags: rick.sapir: documentation+
Hardware: All   
OS: All   
URL: http://wiki.eclipse.org/EclipseLink/Release/2.1.2#Known_Issues
Whiteboard:

Description Ivan Belis CLA 2011-01-21 05:09:00 EST
Build Identifier: 2.1.2.v20101206-r8635

While migrating from EclipseLink 1 to the latest 2.1.2 we have encountered an incompatibillity when using native queries.

The result class of calling getSingleresult on a native query is different between eclipselink version 1.0.2 and 2.1.2

Example:
	Query q = em.createNativeQuery("SELECT '1' FROM dual ");
	Object obj = q.getSingleResult();

In EclipseLink 1.0.2 this will give a List with as first element a BigDecimal.
In EclipseLink 2.1.2 this will return a BigDecimal.

This means that upgrading from a 1 to version 2 means modifying code.

If the current behaviour is correct (as i presume it is) then this should be documented in a release note or an upgrade note.

Another test case but now with multiple columns:
		Query q = em.createNativeQuery("SELECT 1,2 FROM dual ");
		Object obj = q.getSingleResult();

In EclipseLink 1.0.2 this will give a List with as first element a BigDecimal.
In EclipseLink 2.1.2 this will return an Array with as first element a BigDecimal.


Greetings,
Ivan Belis

Reproducible: Always

Steps to Reproduce:
1. Create native query that returns a scalar non entity, for example
	Query q = em.createNativeQuery("SELECT '1' FROM dual ");
	Object obj = q.getSingleResult();
2. Examine the class returned by query.getSingleResult
3. Run with EclipseLink 1 
4. Run with EclipseLink 2
Comment 1 Tom Ware CLA 2011-02-03 09:52:28 EST
This requires a release note.
Comment 2 Rick Sapir CLA 2011-02-03 10:42:29 EST
Added as known issue in 2.1.2 rel notes 

http://wiki.eclipse.org/EclipseLink/Release/2.1.2#Known_Issues

Pls review for technical accuracy.
Comment 3 Rick Sapir CLA 2011-02-03 11:23:23 EST
Doc'd in release note
Comment 4 Ivan Belis CLA 2011-02-05 10:49:04 EST
(In reply to comment #2)
Thank's Rick for adding that to the release note.

Maybe it is also worth mentioning the behavior with a single column (BigDecimal in Eclipselink 2 versus a List with a BigDecimal on in Eclipselink 1).

Greetings,
Ivan Belis 
> Added as known issue in 2.1.2 rel notes 
> 
> http://wiki.eclipse.org/EclipseLink/Release/2.1.2#Known_Issues
> 
> Pls review for technical accuracy.
Comment 5 Eclipse Webmaster CLA 2022-06-09 10:28:38 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink