Re: org.objectstyle.cayenne.CayenneRuntimeException

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Wed Apr 20 2005 - 11:32:16 EDT

  • Next message: Sami Mohammed: "Primary key"

    > criticalLevel= "UYARI";

    Isn't it because the PK above is passed as a String? Try
    DataObjectUtils.pkForObject().

    What I still don't understand is how are you going to store this
    non-numeric value in a DECIMAL column? So... if "criticalLevel" is not an
    id column, then you can't build an ObjectId like that:

    > ErrorLevel level = (ErrorLevel)context.registeredObject(
    > new ObjectId(ErrorLevel.class,"criticalLevel",
    > criticalLevel));

    and should use a select query instead.

    Andrus

    > Hi,
    > I want to get PK for entity criticalLevel of ErrorLevel table. But I get
    > an exception (PK is not a number) for the below code. I define the PK
    > Id: Decimal in DbEntity, BigInteger in ObjectEntity. Can anybody help
    > me.
    >
    > Thanks.
    >
    > Code :
    > criticalLevel= "UYARI";
    > ErrorLevel level = (ErrorLevel)context.registeredObject(
    > new ObjectId(ErrorLevel.class,"criticalLevel",
    > criticalLevel));
    >
    > int levelID = DataObjectUtils.intPKForObject(level);****EXCEPTION
    > THROWS*****
    >
    > Exception:
    > org.objectstyle.cayenne.CayenneRuntimeException: [v.1.1RC2 October 24
    > 2004] PK is not a number: tr.com.htr.hgys.db.ErrorLevel:
    > <criticalLevel: UYARI>
    > at
    > org.objectstyle.cayenne.DataObjectUtils.intPKForObject(DataObjectUtils.java:97)
    > at tr.com.htr.hgys.db.ErrorLogs.setErrorLogs(ErrorLogs.java:26) at
    > tr.com.htr.hgys.db.create.CreateDb.main(CreateDb.java:74)



    This archive was generated by hypermail 2.0.0 : Wed Apr 20 2005 - 11:32:17 EDT