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

Last updated on MARCH 29, 2012

Applies to:

Oracle TopLink - Version: 11.1.1.5.0 and later   [Release: Oracle11g and later ]
Information in this document applies to any platform.

Symptoms


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

Class mEntityClass = hb.test.Emp.class ;
ExpressionBuilder expb = new ExpressionBuilder(mEntityClass);
ReportQuery query = new ReportQuery(mEntityClass, expb);
query.dontUseDistinct();

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

query.useCursoredStream(mPageSize, mPageSize);
query.addAttribute("empnoAt", expb.get("empno"));
query.addAttribute("enameAt", expb.get("ename"));
query.addAttribute("deptnoAt", 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 (Emp) 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 [SMITH], of class [class java.lang.String], from mapping [oracle.toplink.mappings.DirectToFieldMapping[deptno-->SCOTT.EMP.DEPTNO]] with descriptor [RelationalDescriptor(hb.test.Emp --> [DatabaseTable(SCOTT.EMP)])], 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 [SMITH], of class [class java.lang.String], from mapping [oracle.toplink.mappings.DirectToFieldMapping[deptno-->SCOTT.EMP.DEPTNO]] with descriptor [RelationalDescriptor(hb.test.Emp --> [DatabaseTable(SCOTT.EMP)])], 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)

Cause

Sign In with your My Oracle Support account

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

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms