ok I understand the problem! So I think the smoothest way is to
provide a seperate field in the modeler, which could be initially
filled with the DB default values (if there're any).
So you don't have to do a separate invalidation!
Just check on creation if value is equal NULL if so get the default
value out of the mapping xml?
So there will be no problems when upgrading former releases, because
initially the Default field in modeler is not set?

Meex

> Am Jun 24, 2014 um 20:19 schrieb Andrus Adamchik <[email protected]>:
>
>
>
>> I think it's just the INSERT command, a solution would be that only
>> values are inserted that are not NULL?
>
>
> So this would ensure we don’t override the DB defaults. Perhaps you are on to 
> something here. If you are relying on DB defaults, a NULL value would 
> override those (at least on MySQL). Though this presents other problems:
>
> * once you save an object, we need to immediately invalidate it, as it 
> doesn’t contain the defaults that were assigned in the DB.
> * we need to tell NULL apart from “no value” when creating an INSERT.
>
> So yeah, maybe we do need an ability to model a column DB-side default value. 
> Somehow in all the years of Cayenne I didn’t care too much about it, always 
> relying on the app code to initialize all the defaults per application needs. 
> But if we are to support schemas with DEFAULT columns we need to make this 
> change. Actually Cayenne runtime doesn’t even care about the value of the 
> default. Just about the fact that it is there. DDL operations do though.
>
> Something to think about ...
>
> Andrus
>
>> On Jun 24, 2014, at 1:51 PM, Markus Reich <[email protected]> 
>> wrote:
>>
>> Hmm, I think it's just the INSERT command, a solution would be that only
>> values are inserted that are not NULL? As you check on UPDATE, the SET part
>> includes just fields that were really changed?
>>
>> or am I missing sthg.?
>>
>>
>> 2014-06-16 9:56 GMT+02:00 Andrus Adamchik <[email protected]>:
>>
>>> I would personally do it with a postAdd callback, as mentioned in the top
>>> thread in Mike’s list.
>>>
>>> Andrus
>>>
>>>> On Jun 13, 2014, at 4:37 PM, Mike Kienenberger <[email protected]> wrote:
>>>>
>>>> Here are some previous discussions on default values, from most
>>>> current to ancient.
>>>>
>>>> I don't know if this is a complete list.
>>>>
>>>> DB default values
>>> http://mail-archives.apache.org/mod_mbox/cayenne-user/201309.mbox/%3ccagscxrykqbpmm+kbmxhbgag3+uvnfct-xqe6bhtqpaaqnxv...@mail.gmail.com%3E
>>>>
>>>> default value from the modeler ?
>>> http://mail-archives.apache.org/mod_mbox/cayenne-user/201004.mbox/%[email protected]%3E
>>>>
>>>> Handling of database NULL - default value column to modeler?
>>> http://mail-archives.apache.org/mod_mbox/cayenne-user/200808.mbox/%[email protected]%3E
>>>>
>>>> Setting Default Values for Entities
>>> http://mail-archives.apache.org/mod_mbox/cayenne-user/200712.mbox/%[email protected]%3E
>>>>
>>>>
>>>>
>>>>
>>>> On Fri, Jun 13, 2014 at 4:56 AM, Chukwuemeka Mbonu Onwukwe
>>>> <[email protected]> wrote:
>>>>> Hi Markus,
>>>>> I think it would make sense.
>>>>> Definitely.
>>>>>
>>>>> Regards,
>>>>> Emeka
>>>>>
>>>>> On 13 Jun 2014 09:26, "Markus Reich" <[email protected]>
>>> wrote:
>>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> would it make sense to add in Cayennen Modeler a field to set a default
>>>>>> value. Cayenne set's per default all fields to null, if they weren't
>>> set
>>>>> in
>>>>>> Java?
>>>>>>
>>>>>> regards
>>>>>> Meex
>>
>>
>> --
>> *Markus Reich*
>> Moosbach 28/2
>> 6392 St. Jakob i.H.
>> www.markusreich.at / www.meeximum.at
>> [email protected]
>

Reply via email to