You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by "Nick Johnson (JIRA)" <ji...@apache.org> on 2007/11/04 02:57:50 UTC

[jira] Created: (OPENJPA-431) Order INSERT statements on joined subclasses from parent to child

Order INSERT statements on joined subclasses from parent to child
-----------------------------------------------------------------

                 Key: OPENJPA-431
                 URL: https://issues.apache.org/jira/browse/OPENJPA-431
             Project: OpenJPA
          Issue Type: Improvement
          Components: sql
    Affects Versions: 1.0.0
            Reporter: Nick Johnson


When creating a joined subclass relationship, it is desirable on the database side to place an integrity constraint on the subclass table that its object_id must exist in the parent class's table.  (Because the subclass's row cannot exist without the parent class's row.)

Unfortunately, OpenJPA orders the inserts in the opposite direction, trying to insert the child entity first (probably because that's the entity that the code is actually persisting), so with the integrity constraint in place, the insert will fail.

It would be nice if in a joined-subclass relationship where multiple inserts were needed, SQL would be issued in order of highest in the class hierarchy to lowest so that integrity constraints on the database won't be violated.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (OPENJPA-431) Order INSERT statements on joined subclasses from parent to child

Posted by "Nick Johnson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OPENJPA-431?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12540529 ] 

Nick Johnson commented on OPENJPA-431:
--------------------------------------

The suggestion given in OPENJPA-435 does result in the expected insert ordering.

> Order INSERT statements on joined subclasses from parent to child
> -----------------------------------------------------------------
>
>                 Key: OPENJPA-431
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-431
>             Project: OpenJPA
>          Issue Type: Improvement
>          Components: sql
>    Affects Versions: 1.0.0
>            Reporter: Nick Johnson
>
> When creating a joined subclass relationship, it is desirable on the database side to place an integrity constraint on the subclass table that its object_id must exist in the parent class's table.  (Because the subclass's row cannot exist without the parent class's row.)
> Unfortunately, OpenJPA orders the inserts in the opposite direction, trying to insert the child entity first (probably because that's the entity that the code is actually persisting), so with the integrity constraint in place, the insert will fail.
> It would be nice if in a joined-subclass relationship where multiple inserts were needed, SQL would be issued in order of highest in the class hierarchy to lowest so that integrity constraints on the database won't be violated.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Closed: (OPENJPA-431) Order INSERT statements on joined subclasses from parent to child

Posted by "Patrick Linskey (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENJPA-431?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Patrick Linskey closed OPENJPA-431.
-----------------------------------

    Resolution: Invalid

Closing on the assumption that setting the 'openjpa.jdbc.SchemaFactory' to 'native' will resolve the issue. OpenJPA actually re-orders based on FKs in the schema. It is probably failing to re-order in this case because it is not configured to load your foreign keys from the schema (this can be a slow operation), and because you don't have any explicit foreign keys in the model.

As has been discussed in the newsgroup, it would probably be a really good idea for us to change the defaults to assume that foreign keys exist in logical places, such as inheritance hierarchies and relationships. Of course, it's not always easy to say which FK to assume exists.

> Order INSERT statements on joined subclasses from parent to child
> -----------------------------------------------------------------
>
>                 Key: OPENJPA-431
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-431
>             Project: OpenJPA
>          Issue Type: Improvement
>          Components: sql
>    Affects Versions: 1.0.0
>            Reporter: Nick Johnson
>
> When creating a joined subclass relationship, it is desirable on the database side to place an integrity constraint on the subclass table that its object_id must exist in the parent class's table.  (Because the subclass's row cannot exist without the parent class's row.)
> Unfortunately, OpenJPA orders the inserts in the opposite direction, trying to insert the child entity first (probably because that's the entity that the code is actually persisting), so with the integrity constraint in place, the insert will fail.
> It would be nice if in a joined-subclass relationship where multiple inserts were needed, SQL would be issued in order of highest in the class hierarchy to lowest so that integrity constraints on the database won't be violated.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.