RE: BigDecimal vs Integer -- StoredProcedure out parameter vs Query

From: Pirola Davide (davide.pirol..tin.it)
Date: Wed Feb 23 2005 - 03:40:13 EST

  • Next message: emre: "Path error"

    Thank's Andrus... i follow your suggest.
    :)
    Davide

    -----Original Message-----
    From: Andrus Adamchik [mailto:andru..bjectstyle.org]
    Sent: mercoledì 23 febbraio 2005 3.27
    To: cayenne-use..bjectstyle.org
    Subject: Re: BigDecimal vs Integer -- StoredProcedure out parameter vs
    Query

    In the first case Cayenne uses a default Java class for a given JDBC
    type, as it doesn't know about the final object type when the query is
    processed (this is a side effect of using a result set obtained via
    Oracle procedure OUT parameter). In the second case it uses whatever
    class is specified in the object, converting the value returned via
    JDBC...

    I can think of one easy workaround - remove "id" from the ObjEntity and
    instead create a getter based on DataObjectUtils:

    public int getId() {
        return DataObjectUtils.intPKForObject(this);
    }

    Andrus

    On Feb 18, 2005, at 3:58 AM, Pirola Davide wrote:

    > Maybe my mail is a little bit confuse :-)
    >
    > In the first case, i read a record via Stored Procedure (ORACLE CURSOR
    > in out parameter).
    > In the second case i use a normal SelectQuery object:
    >
    > SelectQuery query = new SelectQuery(MyClass.class);
    > ...
    > List objects = context.performQuery(query);
    >
    > At the end i obtain a java object with this kind of fileds:
    >
    > long(or int) id;
    > String filed1;
    > String filed2;
    > ....
    >
    > The id, in the first case, is returned as BigDecimal.
    > In the second case is returned as Integer.
    >
    > So i can't use the same java object... or i must make a supplementary
    > control:
    >
    > public int getId() {
    > return readProperty("id") instanceof BigDecimal ?
    > ((BigDecimal) readProperty("id")).intValue() : readProperty("id")
    > instanceof Integer ? ((Integer) readProperty("id")).intValue() : 0;
    > }
    >
    > Anyhow, both StoredProcedure and Select Query (on Oracle) are
    > identical.
    >
    > Thank's.
    > Davide
    >
    >
    >
    >
    > -----Original Message-----
    > From: Pirola Davide
    > Sent: giovedì 17 febbraio 2005 17.15
    > To: 'cayenne-use..bjectstyle.org'
    > Subject: BigDecimal vs Integer -- StoredProcedure out parameter vs
    > Query
    >
    >
    > Hi,
    > i have two way for access to my data in a table.
    >
    > 1)Stored procedure out parameter.
    >
    > 2)SelecQuery
    >
    > In all the cases this is the query executed :
    >
    > "SELECT id,field1, field2 ... FROM mytable WHERE id = myvalue"
    >
    > When i map this record to my java object, in the first case the id
    > value is returned by cayenne as BigDecimal, in the second case as
    > Integer.
    >
    > Why?
    >
    > I prefer to use Integer... how i can tell to cayenne to handle oralce
    > number type as Integer value?
    >
    > (i have alreay mapped this with java.lang.Integer in data map xml file)
    >



    This archive was generated by hypermail 2.0.0 : Wed Feb 23 2005 - 03:39:28 EST