My Oracle Support Banner

Conversion Exception When Using Setshouldretrieveprimarykeys(True) On Reportquery Using Toplink 11.1.1.5.0 (Doc ID 1435765.1)

Last updated on MARCH 29, 2019

Applies to:

Oracle TopLink - Version 11.1.1.5.0 and later
Information in this document applies to any platform.

Symptoms

Disclaimer

NOTE: In the images and/or the document content below, the user information and data used represents fictitious data from the Oracle sample schema(s) or Public Documentation delivered with an Oracle database product. Any similarity to actual persons, living or dead, is purely coincidental and not intended in any manner.

 


Using toplink 11.1.1.5 , a ReportQuery is defined and executed,
and results are obtained via CursoredStream object as the following :

Class employeeloyee = Employee.class ;
ExpressionBuilder expb = new ExpressionBuilder(employee);
ReportQuery query = new ReportQuery(employee, expb);
query.dontUseDistinct();

if (setShouldRetrievePrimaryKeys)
query.setShouldRetrievePrimaryKeys(true);
else query.setShouldRetrievePrimaryKeys(false);

query.useCursoredStream(PageSize, PageSize);
query.addAttribute("empno", expb.get("empno"));
query.addAttribute("ename", expb.get("ename"));
query.addAttribute("deptno", expb.get("deptno"));

CursoredStream stream = (CursoredStream) session.executeQuery(query);

while (! stream.atEnd()) {
ReportQueryResult employee = (ReportQueryResult) stream.read();
System.out.println(" emp" + employee);
stream.releasePrevious();
}
stream.close()



The Report Query is done against an entity (Employee) and is working
well when query.setShouldRetrievePrimaryKeys(false); Or setShouldRetrievePrimaryKeys is not invoked.


The problem is happening when calling query.setShouldRetrievePrimaryKeys(true);
In that case the following exception is happening when executing the query :
CursoredStream stream = (CursoredStream) session.executeQuery(query);


TopLink Warning]: 2011.12.15 14:28:49.219--ServerSession(10817575)--Exception [TOPLINK-3002] (Oracle TopLink - 11g Release 1 (11.1.1.5.0) (Build 110305)): oracle.toplink.exceptions.ConversionException
Exception Description: The object [JOHN DOE], of class [class java.lang.String], from mapping [oracle.toplink.mappings.DirectToFieldMapping[deptno-->Employee.DEPTNO]] with descriptor [RelationalDescriptor(Emp --> [DatabaseTable(EMPLOYEE)])], could not be converted to [class java.math.BigDecimal].
Internal Exception: java.lang.NumberFormatException
Local Exception Stack:
Exception [TOPLINK-3002] (Oracle TopLink - 11g Release 1 (11.1.1.5.0) (Build 110305)): oracle.toplink.exceptions.ConversionException
Exception Description: The object [JOHN DOE], of class [class java.lang.String], from mapping [oracle.toplink.mappings.DirectToFieldMapping[deptno-->Employee.DEPTNO]] with descriptor [RelationalDescriptor(Emp --> [DatabaseTable(EMPLOYEE)])], could not be converted to [class java.math.BigDecimal].
Internal Exception: java.lang.NumberFormatException
at oracle.toplink.exceptions.ConversionException.couldNotBeConverted(ConversionException.java:68)
at oracle.toplink.internal.helper.ConversionManager.convertObjectToBigDecimal(ConversionManager.java:190)
at oracle.toplink.internal.helper.ConversionManager.convertObject(ConversionManager.java:118)
at oracle.toplink.internal.databaseaccess.DatasourcePlatform.convertObject(DatasourcePlatform.java:143)
at oracle.toplink.platform.database.oracle.Oracle9Platform.convertObject(Oracle9Platform.java:338)
at oracle.toplink.mappings.foundation.AbstractDirectMapping.getAttributeValue(AbstractDirectMapping.java:429)
at oracle.toplink.queryframework.ReportQueryResult.processItem(ReportQueryResult.java:158)
at oracle.toplink.queryframework.ReportQueryResult.buildResult(ReportQueryResult.java:123)
at oracle.toplink.queryframework.ReportQueryResult.<init>(ReportQueryResult.java:63)
at oracle.toplink.queryframework.ReportQuery.buildObject(ReportQuery.java:574)

Changes

 

Cause

To view full details, sign in with your My Oracle Support account.

Don't have a My Oracle Support account? Click to get started!


In this Document
Symptoms
Changes
Cause
Solution
References


My Oracle Support provides customers with access to over a million knowledge articles and a vibrant support community of peers and Oracle experts.