Ah, I see what you mean. So following any insert, it would have to do a
select for any database generated columns, and update the object
accordingly. Not as trivial as I first thought.
Mike
(It would be helpful if the list server set the reply-to header to
cayenne-use..bjectstyle.org, so that replying to mail list messages
directed the reply back to the list.)
Andrus Adamchik wrote:
> [copying this back to the list]
>
>> I am not clear on what you mean by "pass default value back to the
>> object on commit". If the column participates in an insert or update
>> then the database will not use the defined default value.
>
>
> I mean that if DB generates a value, a DataObject has to know somehow
> what value was generated and a corresponding object property has to be
> updated... Short of refetching the object, this part is not a clear
> cut....
>
> Andrus
>
>
>
> On Jan 16, 2005, at 4:05 AM, Mike D Pilsbury wrote:
>
>> Thanks Andrus, it's good to know that support for this is on its way,
>> as I think that it is a serious omission.
>>
>> I am not clear on what you mean by "pass default value back to the
>> object on commit". If the column participates in an insert or update
>> then the database will not use the defined default value.
>>
>> For now I will have to explicitly set the property (to the current
>> time) as you suggest. It is definitely a workaround, as the
>> application server's time may not be the same as the database
>> server's time (or even timezone).
>>
>> Mike
>>
>>
>> Andrus Adamchik wrote:
>>
>>> Hi Mike,
>>>
>>> I am currently working on finalizing the auto-generated columns
>>> code. This should be released in the next 1.2 milestone. I will
>>> still need to test it with default column values. I wonder if the
>>> mechanism for value retrieval of "default" columns is the same as
>>> for generated keys (as in addition to skipping such columns in
>>> INSERT we need to pass default value back to the object on commit)...
>>>
>>> For now I guess the workaround is to set this property explicitly to
>>> a non-null value, e.g. in validateForInsert() or in
>>> setPersistenceState().
>>>
>>> Andrus
>>>
>>>
>>> On Jan 15, 2005, at 7:07 PM, Mike D Pilsbury wrote:
>>>
>>>> I have a column that is defined as having a default value (actually
>>>> CURRENT_TIMESTAMP, but it shouldn't matter). When I create a new
>>>> object, and it gets committed, the generated INSERT sets the column
>>>> to null. But this obviously stops the database from using the
>>>> default value.
>>>>
>>>> So what I want to know is how do I configure Cayenne so that it
>>>> ignores the column for INSERTs and UPDATEs, but gets it for
>>>> selects? I tried setting the column to Auto (isGenerated), but that
>>>> appears to have no effect. I know that Hibernate supports this. so
>>>> I don't doubt that Cayenne does too.
>>>>
>>>> I am a newbie to Cayenne, so I am sure that it is something simple
>>>> that I am not finding, despite searching the docs and the mailing
>>>> list.
>>>>
>>>> Mike
>>>
>>>
>>>
>>>
>>
>
>
This archive was generated by hypermail 2.0.0 : Sun Jan 16 2005 - 16:14:32 EST