Re: PostgreSQL Money type

From: Chris Gamache (cgamach..mail.com)
Date: Tue Oct 09 2007 - 17:13:27 EDT

  • Next message: Mike Kienenberger: "Does DataContext.rollbackChanges() in 1.1.4 leave transient objects in toManyList relationships?"

    On 10/9/07, Michael Gentry <blacknex..mail.com> wrote:
    > In the modeler, for the DbEntity, try using the NUMERIC (or maybe even
    > DECIMAL, but try NUMERIC first) type and for the ObjEntity it should
    > sync up as a java.math.BigDecimal. Set the scale to 2 (if you want 2
    > places after the decimal point).

    When I follow the recipe above I get
    ERROR: column "charge" is of type money but expression is of type numeric

    Which is typical when strongly typed PostgreSQL gets its feathers
    ruffled. I was really hoping that the simple and elegant solution
    would work.

    I think I've found the correct solution, again, involving an ExtendedType.

    PostgreSQL JDBC driver comes with a PGmoney class. If you specify
    Types.OTHER and org.postgresql.util.PGmoney and create an ExtendedType
    and register it with your datanode it appears to work as expected.

    > Also, according to the PostgreSQL documentation, the money
    > type is deprecated:

    It's been deprecated for something like 6 years now. I'm still waiting
    for the other shoe to drop! It seems like more work to retool for
    numeric(10,2) than to shoehorn yet another type into Cayenne. Cayenne
    seems to be able to do anything I want it to.

    Thank you again for your fantastic work on this product. You'll hear
    me say it over and over.

    CG



    This archive was generated by hypermail 2.0.0 : Tue Oct 09 2007 - 17:14:00 EDT