cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Gentry <mgen...@masslight.net>
Subject Re: Transaction Fails - when saving interdependent entities.
Date Wed, 06 Jun 2012 12:50:25 GMT
Hi Kanwar,

1. This is something that will require a bit of coding which you may
not want to delve into, so I suggest altering your constraints to be
deferrable.  I'll create a JIRA for us to track adding it to the
commitChanges() logic (at least for the PostgreSQL adapter).  Also in
the initial FK constraints produced by Cayenne Modeler.

2. Not with the current implementation.  Ideally, you shouldn't care
and I'd even argue that you don't want to have to manage such things
in your code since that is more of a database domain issue.

mrg

On Wed, Jun 6, 2012 at 4:13 AM, Kanwar Manish <kanwarmanish@gmail.com> wrote:
> Hi Michael
>
> 1. How do I execute - "SET CONSTRAINTS ALL DEFERRED"? I understand this is
> applicable for the current transaction only so this needs to be executed
> every time I want to use "commitChanges()"?
>
> 2. Can this be done ? That the sequence of committing [saving objects] in a
> transaction is similar to the sequence of creation of new objects from the
> DataContext?
>
> Thanks
> KM
>
> On Wed, Jun 6, 2012 at 1:30 AM, Michael Gentry <mgentry@masslight.net>wrote:
>
>> Hi Gilberto,
>>
>> With Cayenne, you model the relationships between tables/objects and
>> Cayenne can build a dependency graph of what needs inserted first
>> (mainly useful for auto-generated keys), but currently there is no
>> mechanism in Cayenne to model the database constraints which can
>> further influence the dependency graph.
>>
>> I'd say deferred constraints can be useful even for small amounts of
>> data.  From my perspective, I care about the integrity of the data at
>> the end of the transaction, not in the middle, even if the transaction
>> only has a few statements.
>>
>> Turning on the logs (if they aren't already on) is unlikely to help in
>> this case.  I know from past experience that the dependency graph
>> produced by the EntitySorter isn't always the same from run-to-run
>> (there can be different, but valid, dependency graphs for a set of
>> operations).  Most likely deferring the constraints will solve the
>> issue.  And at least PostgreSQL allows you to do that.  :-)
>>
>> mrg
>>
>>
>> On Tue, Jun 5, 2012 at 3:44 PM, gilbertoca <gilbertoca@gmail.com> wrote:
>> >
>> > Michael Gentry-2 wrote
>> >>
>> >> Cayenne currently does not know about how your database constraints are
>> >> structured (even though
>> >> when it generates the schema it can add some constraints).
>> >>
>> >
>> > I think Cayenne is very intelligent and know the correct order to execute
>> > the statements, doesn't it?
>> >
>> > Michael, in my little experience in Database I would say that the common
>> use
>> > of the deferred integrity constraints is when dealing with large volumes
>> of
>> > data being inserted into tables.[1]
>> >
>> > Maybe enabling  the Cayenne log to show us how the statements are
>> ordered we
>> > could see another symptom.
>> > Regards
>> >
>> > Gilberto
>> >
>> >
>> > --
>> > View this message in context:
>> http://cayenne.195.n3.nabble.com/Transaction-Fails-when-saving-interdependent-entities-tp4024215p4024219.html
>> > Sent from the Cayenne - User mailing list archive at Nabble.com.
>>

Mime
View raw message