Cayenne supports EJBQL[1] and SQLTemplate[2] for this sort of thing. Not
sure if Cayenne is 100% EJBQL compliant though?

But if all else fails fallback to SQLTemplate :)

kind regards

Bob

[1]: https://cayenne.apache.org/docs/4.1/cayenne-guide/#ejbql
[2]: https://cayenne.apache.org/docs/4.1/cayenne-guide/#sqltemplate

On Tue, Aug 14, 2018 at 10:11 PM Tony Giaccone <tgiacc...@gmail.com> wrote:

> I have an object that contains a to many relationship to potentially 100's
> of thousands of objects.  I read in a file and generate this relationship
> based on the contents of that file.
>
> Imagine that after the relationship has been created, we realize that the
> file contained errors and we want to recreate this relationship by reading
> a new file that describes the complete set of entries in the relationship.
>
> Note, I don't want to delete the objects that make up the toMany
> relationship. I just want to break the relationship between the source and
> the many destination objects.
>
> My first thought is to null out the relationship, There's a foreign key in
> the dependent object that describes its parent.  So first step is set all
> those values to null.
>
> Then I'll iterate through the list, recreating the relationship based on
> the contents of the file.
>
> This is the brute force approach that solves the problem of what do I do
> about entries in the old list that aren't in the new list.
>
> My question is this. Is there an easy way to break that connection. I
> looked didn't see anything.
>
> Essentially want to do this:
>
> Assume two tables t1,t2.
> There is a to-Many relationship between t1 and t2.  The foreign key column
> in table t2 is fkt1.
>
> update t2   set fkt1 = null where fkt1 = %A_VALUE;
>
> This is kind of counter to the Cayenne way of doing things, but it's a
> large number of objects and I can't see the point in iterating through them
> on by one to delete the relationship.
>
>
>
>
> Tony
>

Reply via email to