[baseten-users] ERROR: null value in column "xyz" violates not-null constraint when trying to insert mandatory data
Tuukka Norri
tuukka.norri at karppinen.fi
Sat May 23 16:19:24 EEST 2009
Hi!
Réjean Lamy kirjoitti 23.5.2009 kello 15.41:
> It is mentioned "..the context needs to know about your objects:
> that's why you can't just go and instantiate BXDatabaseObjects on
> your own."
> And the recommendation about using createObjectForEntity:entity.
>
> Questions:
>
> May I conclude that unlike CoreData, this is not possible to simply
> instantiate a BXDatabaseObjects, instead we must first create the
> objects as explained ?
That's correct. This way we get the database to set default values,
call INSERT triggers, increment the sequence used by a SERIAL column
etc.
> Also, I would like to know where is the recommended place in code to
> creates the BXDatabaseObjects (In App Controller -init, -
> awakeFromNib, others...) ?
It should be possible to do this anywhere. The database context needs
to be connected, though.
BXSyncrhonizedArrayController's methods -newObject and -createObject:
call the database context's creation method, so if your application
uses the array controller, you might want to call them instead.
--
Best regards,
Tuukka Norri
MK&C
More information about the baseten-users
mailing list