You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by atomix <sa...@yahoo.com> on 2012/03/09 02:58:18 UTC

[HELP] Problem: Cayenne - ORM and "TEMP" tables

I had a situation, not completely related to Cayenne only, may be every ORM
framework...

Say I had a Test, the Test has Question(s) ,a Question can be in various
Test
Test -n-n- Question for short.
Also, in TestHasQuestion table has a property of order, and value of the
Question in a specific the Test.

Here is the problem:
The every update in a Test have to be approved (by Maker and Approver)

So basicly, a Maker do a lot of changes in a Test, then submit it in a Temp
Table (which have almost same structure), then Approver accept or reject,
the Test should be return to its previous APPROVED status.
---------------------------------------------------------
Yes, the scenerio for 1 Table is pretty simple to imagine...
Now, Question also -1-n- to Answers. Answers also link to another Table..
...
and I confused a lot how to work out the case in a ORM system like Cayenne.
It can be handle in a simpler enviroment like SQL, but the whole tables are
linked together in Cayenne...

Just few temp-tables make my life suck big times ....
... 

--
View this message in context: http://cayenne.195.n3.nabble.com/HELP-Problem-Cayenne-ORM-and-TEMP-tables-tp3811483p3811483.html
Sent from the Cayenne - User mailing list archive at Nabble.com.

Re: [HELP] Problem: Cayenne - ORM and "TEMP" tables

Posted by atomix <sa...@yahoo.com>.
@Mike , thanks a ton! Really appreciate!

I take your suggestion ... the reason I didn't take it sooner because I
don't want to change the structrure of the orginal tables.

After some changes, they all work fine!

--
View this message in context: http://cayenne.195.n3.nabble.com/HELP-Problem-Cayenne-ORM-and-TEMP-tables-tp3811483p3844305.html
Sent from the Cayenne - User mailing list archive at Nabble.com.

Re: [HELP] Problem: Cayenne - ORM and "TEMP" tables

Posted by Mike Kienenberger <mk...@gmail.com>.
If it were me, I would add a status column to the Test table
(approved, pending-approval, maybe rejected).
Then I would store both approved tests and pending-approval tests in
the same tables rather than using identical temporary tables.

You might also consider adding a related_parent_test_id column to the
Test table, so you can quickly identify which tests are related
revisions of each other.

When a Maker makes a change to a test, make a new pending-approval
copy of the Test, linking it back to the original.

When an Approver approves it, delete the original (or mark it as
obsolete) and mark the new test as approved.   When an approver
rejects it, delete the copy (or mark it as rejected).


Another approach would be to add the status column to each table.
Instead of copying the entire test, just maintain the differences
between the approved test records and the pending-approval test
records.  Possibly you'd use status items like (pending-addition,
pending-removal, pending-modification).   Then you don't need to
maintain and copy entire tests.


But in any case, I would avoid separate identical tables.

On Thu, Mar 8, 2012 at 8:58 PM, atomix <sa...@yahoo.com> wrote:
> I had a situation, not completely related to Cayenne only, may be every ORM
> framework...
>
> Say I had a Test, the Test has Question(s) ,a Question can be in various
> Test
> Test -n-n- Question for short.
> Also, in TestHasQuestion table has a property of order, and value of the
> Question in a specific the Test.
>
> Here is the problem:
> The every update in a Test have to be approved (by Maker and Approver)
>
> So basicly, a Maker do a lot of changes in a Test, then submit it in a Temp
> Table (which have almost same structure), then Approver accept or reject,
> the Test should be return to its previous APPROVED status.
> ---------------------------------------------------------
> Yes, the scenerio for 1 Table is pretty simple to imagine...
> Now, Question also -1-n- to Answers. Answers also link to another Table..
> ...
> and I confused a lot how to work out the case in a ORM system like Cayenne.
> It can be handle in a simpler enviroment like SQL, but the whole tables are
> linked together in Cayenne...
>
> Just few temp-tables make my life suck big times ....
> ...
>
> --
> View this message in context: http://cayenne.195.n3.nabble.com/HELP-Problem-Cayenne-ORM-and-TEMP-tables-tp3811483p3811483.html
> Sent from the Cayenne - User mailing list archive at Nabble.com.