Re: DB column default values are not supported?

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Wed Oct 01 2008 - 13:29:32 EDT

  • Next message: Dave Dombrosky (JIRA): "[jira] Created: (CAY-1114) EJBQLQuery fails on joins outside of public schema"

    I am using prePersist callback to set the defaults.

    Wouldn't mind having it set via Modeler (and you do correctly point
    out to the problems with String to data type conversion). So this was
    'Cayenne-only default values'.

    Now if we are talking about syncing Cayenne with DB default values,
    this becomes a bit more tricky, as on INSERT JDBC driver does not pass
    back the default values that were set. Although I guess if we know
    them from the mapping, we can just automatically apply them to objects
    to suppress DB setting them.

    Anyways, maybe that's another candidate to be implemented as "internal
    callback listener" initiated from the model.

    Andrus

    On Oct 1, 2008, at 8:01 PM, Andrey Razumovsky wrote:

    > Hello,
    >
    > It seems DB column default values are not supported in Cayenne. This
    > is no
    > good, and even worse, I cannot setup those values at database level,
    > because
    > Cayenne will nullify them anyways - InsertBatchQueryBuilder creates
    > insert
    > for all DbAttributes. I think that if we support max-length and
    > scale, we
    > should support this too. BTW, I was told Hibernate supports this
    > feature.
    > At best we should have that property in DbAttribute and use it along
    > DB
    > engineering and reverse-engineering. Of course this is no easy task,
    > because
    > we have different types of attributes, e.g. dates (I mean modeler
    > support
    > here).
    > Currently the best way to workaround seems to be setting default
    > values in
    > constructor.
    >
    > What do you think?



    This archive was generated by hypermail 2.0.0 : Wed Oct 01 2008 - 13:30:04 EDT