Ok, I bet your guess is right after thinking about it, so i will just
get my objects from dc.
Regards && happy new year
Michael Gentry wrote:
> Keep in mind Cayenne objects are designed to work in a DataContext as
> it tracks changes, etc. It is best to create them in the DC even if
> you never persist them later (you can throw the DC away if you want).
> Cayenne creates temporary IDs for objects and because you didn't
> create it in the DC, the ID is probably null and that's why you are
> getting the NPE. (At least that is my first guess.)
>
> I use my Cayenne objects (the non-underscore) ones as beans,
> essentially, often. Works just fine, but I always create them in the
> DC, too. I also put my business logic in the non-underscore classes,
> too. No issues with that.
>
> mrg
>
>
> On Thu, Dec 31, 2009 at 5:26 PM, Marek Šabo <msab..uk.cvut.cz> wrote:
>
>> Hi,
>>
>> another thing, I was thinking whether it is possible or not to use generated
>> dataObjects (not the underscored ones) as beans. I defined a constructor and
>> filled in all attributes but when I tried to fill foreign key attribue (a
>> user in reservation object) stack run into null pointer exception in
>> setToOneTarget method on line getObjectContext().propertyChanged(this,
>> relationshipName, oldTarget, value);
>> It is logicall that datacontext is null as I didn't want any persistance
>> (and didn't create this object with newObject method) just models, the
>> question is why the holdup on foreign key? Other attributes were passed just
>> fine. Or how it is generally done -- e.g. there is another subset of beans
>> same as dataObjects for business logic purposes or can it be done the way I
>> see it? Frankly, that was the first thing that I got on my mind when I saw
>> that dataObjects extending _autoClasses.
>>
>> Regards
>>
>> --
>> Marek Šabo
>> Chief Server Manager
>> Club SU CVUT Buben
>> Bubenečská Kolej
>> Terronská 28, Prague 16000
>> XMPP: zeratul02..mail.com
>>
>>
>>
>
>
-- Marek Šabo Chief Server Manager Club SU CVUT Buben Bubenečská Kolej Terronská 28, Prague 16000 XMPP: zeratul02..mail.com
This archive was generated by hypermail 2.0.0 : Thu Dec 31 2009 - 17:46:40 EST