RE: [question] Expression.fromString() and handling of Long Objects

From: Budhiraja, Nikhil \(Contractor\) ("Budhiraja,)
Date: Tue Jan 04 2005 - 11:50:11 EST

  • Next message: Laszlo Spoor: "RE: [question] Expression.fromString() and handling of Long Objects"

    Try using

    ExpressionFactory.matchExp(keyPath,operand2)

    It works for me..

    -----Original Message-----
    From: Laszlo Spoor [mailto:lspoor_cayenn..otmail.com]
    Sent: Tuesday, January 04, 2005 6:58 AM
    To: cayenne-use..bjectstyle.org
    Subject: [question] Expression.fromString() and handling of Long Objects

    MySQL : 4.1
    Cayenne: 1.1

    Hi everyone,

    I have noticed the following:

    This code:

        Long myId = new Long ("216201000180");
        [...]
        SelectQuery qcw = new SelectQuery(Employee.class);
        Expression exp = Expression.fromString("empCode = " +
    myId.toString());
        qcw.setQualifier(exp);
        mContext.performQuery(qcw);

    This results in in an 'org.objectstyle.cayenne.exp.ExpressionException'.

    'empCode' is of type long/bigint. When examining the stackTrace, I have
    noticed that 216201000180 is being handled as an Integer, not a Long.

    The workaround is to use 'empCode' as a String, but this is not the way
    things should work, I guess.

    So, am I doing something wrong (if so, what) or should I log this a bug
    somewhere (if so, where :-)?

    Kind regards, Laszlo

    PS: the Stacktrace:

    org.objectstyle.cayenne.exp.ExpressionException: [v.1.1 December 6 2004]
    For
    input string: "216201000180"
            at
    org.objectstyle.cayenne.exp.Expression.fromString(Expression.java:234)
            at
    org.pva.handler.test.WngCpxResolverHandlerTester.testGetCustomWoning(Wng
    CpxResolverHandlerTester.java:77)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav
    a:39)
            at
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
    Impl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:585)
            at junit.framework.TestCase.runTest(TestCase.java:154)
            at junit.framework.TestCase.runBare(TestCase.java:127)
            at junit.framework.TestResult$1.protect(TestResult.java:106)
            at junit.framework.TestResult.runProtected(TestResult.java:124)
            at junit.framework.TestResult.run(TestResult.java:109)
            at junit.framework.TestCase.run(TestCase.java:118)
            at
    org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTe
    stRunner.java:474)
            at
    org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRun
    ner.java:342)
            at
    org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRu
    nner.java:194)
    Caused by: java.lang.NumberFormatException: For input string:
    "216201000180"
            at
    java.lang.NumberFormatException.forInputString(NumberFormatException.jav
    a:48)
            at java.lang.Integer.parseInt(Integer.java:459)
            at java.lang.Integer.valueOf(Integer.java:526)
            at
    org.objectstyle.cayenne.exp.parser.ExpressionParserTokenManager.makeInt(
    ExpressionParserTokenManager.java:118)
            at
    org.objectstyle.cayenne.exp.parser.ExpressionParserTokenManager.TokenLex
    icalActions(ExpressionParserTokenManager.java:1585)
            at
    org.objectstyle.cayenne.exp.parser.ExpressionParserTokenManager.getNextT
    oken(ExpressionParserTokenManager.java:1459)
            at
    org.objectstyle.cayenne.exp.parser.ExpressionParser.jj_ntk(ExpressionPar
    ser.java:1350)
            at
    org.objectstyle.cayenne.exp.parser.ExpressionParser.scalarExpression(Exp
    ressionParser.java:763)
            at
    org.objectstyle.cayenne.exp.parser.ExpressionParser.simpleCondition(Expr
    essionParser.java:275)
            at
    org.objectstyle.cayenne.exp.parser.ExpressionParser.notCondition(Express
    ionParser.java:226)
            at
    org.objectstyle.cayenne.exp.parser.ExpressionParser.andCondition(Express
    ionParser.java:134)
            at
    org.objectstyle.cayenne.exp.parser.ExpressionParser.orCondition(Expressi
    onParser.java:94)
            at
    org.objectstyle.cayenne.exp.parser.ExpressionParser.expression(Expressio
    nParser.java:87)
            at
    org.objectstyle.cayenne.exp.Expression.fromString(Expression.java:227)
            ... 14 more

    _________________________________________________________________
    MSN Search, for accurate results! http://search.msn.nl



    This archive was generated by hypermail 2.0.0 : Tue Jan 04 2005 - 11:50:33 EST