You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cayenne.apache.org by Andrey Razumovsky <ra...@gmail.com> on 2008/10/01 19:01:42 UTC
DB column default values are not supported?
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?
Re: DB column default values are not supported?
Posted by Robert Zeigler <ro...@gmail.com>.
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?
Re: DB column default values are not supported?
Posted by Andrus Adamchik <an...@objectstyle.org>.
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?