FAQ
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?

Search Discussions

  • Robert Zeigler at Oct 1, 2008 at 5:23 pm
    Current best-practice workaround would probably be to set the default
    values in a pre-persist listener, rather than in the constructor.

    Robert
    On Oct 1, 2008, at 10/112: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?
  • Andrus Adamchik at Oct 1, 2008 at 5:30 pm
    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?

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupdev @
categoriescayenne
postedOct 1, '08 at 5:02p
activeOct 1, '08 at 5:30p
posts3
users3
websitecayenne.apache.org

People

Translate

site design / logo © 2022 Grokbase