You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by "Fay Wang (JIRA)" <ji...@apache.org> on 2009/05/01 01:35:30 UTC

[jira] Created: (OPENJPA-1057) ConstraintUpdateManager fails to order the update/insert/delete rows properly when @SecondaryTable is used

ConstraintUpdateManager fails to order the update/insert/delete rows properly when @SecondaryTable is used
----------------------------------------------------------------------------------------------------------

                 Key: OPENJPA-1057
                 URL: https://issues.apache.org/jira/browse/OPENJPA-1057
             Project: OpenJPA
          Issue Type: Bug
          Components: jdbc
    Affects Versions: 2.0.0
            Reporter: Fay Wang
            Assignee: Fay Wang
             Fix For: 2.0.0


ConstraintUpdateManager fails to order the update/insert/delete rows properly when @SecondaryTable is used to store the entity in different tables.

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


[jira] Updated: (OPENJPA-1057) Foreign keys are not properly set for ConstraintUpdateManager to determine the correct order of the sql

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

Fay Wang updated OPENJPA-1057:
------------------------------

    Description: 
In the following situations, foreign keys are not properly set in the RowImpl for ConstraintUpdateManager to correctly determine the order of sql:

(1) bottom-up table creation for primary table and secondary table with foreign key referencing the primary table: Both primary and secondary tables are used to store the data in an entity, which has the annotation as below:

   @Table(name="Tbl1")   
   @SecondaryTable(name="Tbl2",pkJoinColumns=@PrimaryKeyJoinColumn(name="ID"))   
   public class EntityA implements Serializable {
 
...
    }

In this situation, Openjpa fails to record the foreign key information in the secondary row. Without the foreign key constraint information, the ConstraintUpdateManager is unable to determine the ordering correctly.

(2) bottom up table creation for an entity and its toOne/toMany relation with foreign key constraint. For example:

create table Bidir1to1A (id integer not null, age integer not null, name varchar(30), primary key (id));
create table Bidir1to1B (id integer not null, name varchar(30), entitya_id integer, primary key (id));
alter table Bidir1to1B add constraint FK452ACC2BD7410520 foreign key (entitya_id) references Bidir1to1A;

In this situation, Openjpa reads in the database foreign key constraint. If the relation field does not have ForeignKey annotation, or the ForeignKey annotation has deleteAction set to DEFAULT:

    @OneToOne(cascade=CascadeType.REMOVE)  
    @ForeignKey(deleteAction=ForeignKeyAction.DEFAULT)
    public Unidir1to1B  entityb;

this foreign key constraint will not be recorded in the RowImpl due to the deleteAction = ForeignKey.ACTION_NONE. The lack of foreign key constraint information in the RowImpl leads to the wrong ordering of the sql by the ConstraintUpdateManager.

  was:
In the following situations, foreign keys are not properly set in the RowImpl for ConstraintUpdateManager to correctly determine the order of sql:

(1) bottom-up table creation for primary table and secondary table with foreign key referencing the primary table: Both primary and secondary tables are used to store the data in an entity, which has the annotation as below:

   @Table(name="Tbl1")   
   @SecondaryTable(name="Tbl2",pkJoinColumns=@PrimaryKeyJoinColumn(name="ID"))   
   public class EntityA implements Serializable {
 
...
    }

In this situation, Openjpa fails to record the foreign key information in the secondary row. Without the foreign key constraint information, the ConstraintUpdateManager is unable to determine the ordering correctly.

(2) bottom up table creation for an entity and its toOne/toMany relation with foreign key constraint. For example:

create table Bidir1to1A (id integer not null, age integer not null, name varchar(30), primary key (id));
create table Bidir1to1B (id integer not null, name varchar(30), entitya_id integer, primary key (id));
alter table Bidir1to1B add constraint FK452ACC2BD7410520 foreign key (entitya_id) references Bidir1to1A;

In this situation, Openjpa reads in the database foreign key constraint. However, this foreign key constraint is not recorded in the RowImpl due to the deleteAction = ForeignKey.ACTION_NONE. The lack of foreign key constraint information in the RowImpl leads to the wrong ordering of the sql by the ConstraintUpdateManager.

(3) top-down table creation with the following entity defintion:

@Entity
@Table(name="EntityA")   
public class Unidir1to1A implements IUnidir1to1A, Serializable {

    private static final long serialVersionUID = -1734942085082845941L;

    @Id
    Integer id;

    @OneToOne(cascade=CascadeType.REMOVE)  
    @ForeignKey(deleteAction=ForeignKeyAction.DEFAULT)
    public Unidir1to1B  entityb;

The deleteAction set to ForeignKeyAction.DEFAULT is translated to ForeignKey.ACTION_NONE (for DB2 at least). As in case (2) above, this leads to missing foreign key constraint in the RowImpl, resulting in wrong ordering of the sql.

Note that the wrong ordering of sql means that the sql that insert into the parent table is not executed prior to the sql that insert into the child table.

The fix is:
(1) add foreign key constraint to the RowImpl when @SecondaryTable is used
(2) record foreign key constraint regardless of ForeignKey delete action.   




















> Foreign keys are not properly set for ConstraintUpdateManager to determine the correct order of the sql
> -------------------------------------------------------------------------------------------------------
>
>                 Key: OPENJPA-1057
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-1057
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jdbc
>    Affects Versions: 2.0.0
>            Reporter: Fay Wang
>            Assignee: Fay Wang
>             Fix For: 2.0.0
>
>
> In the following situations, foreign keys are not properly set in the RowImpl for ConstraintUpdateManager to correctly determine the order of sql:
> (1) bottom-up table creation for primary table and secondary table with foreign key referencing the primary table: Both primary and secondary tables are used to store the data in an entity, which has the annotation as below:
>    @Table(name="Tbl1")   
>    @SecondaryTable(name="Tbl2",pkJoinColumns=@PrimaryKeyJoinColumn(name="ID"))   
>    public class EntityA implements Serializable {
>  
> ...
>     }
> In this situation, Openjpa fails to record the foreign key information in the secondary row. Without the foreign key constraint information, the ConstraintUpdateManager is unable to determine the ordering correctly.
> (2) bottom up table creation for an entity and its toOne/toMany relation with foreign key constraint. For example:
> create table Bidir1to1A (id integer not null, age integer not null, name varchar(30), primary key (id));
> create table Bidir1to1B (id integer not null, name varchar(30), entitya_id integer, primary key (id));
> alter table Bidir1to1B add constraint FK452ACC2BD7410520 foreign key (entitya_id) references Bidir1to1A;
> In this situation, Openjpa reads in the database foreign key constraint. If the relation field does not have ForeignKey annotation, or the ForeignKey annotation has deleteAction set to DEFAULT:
>     @OneToOne(cascade=CascadeType.REMOVE)  
>     @ForeignKey(deleteAction=ForeignKeyAction.DEFAULT)
>     public Unidir1to1B  entityb;
> this foreign key constraint will not be recorded in the RowImpl due to the deleteAction = ForeignKey.ACTION_NONE. The lack of foreign key constraint information in the RowImpl leads to the wrong ordering of the sql by the ConstraintUpdateManager.

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


[jira] Updated: (OPENJPA-1057) Foreign keys are not properly set for ConstraintUpdateManager to determine the correct order of the sql

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

Fay Wang updated OPENJPA-1057:
------------------------------

    Affects Version/s:     (was: 2.0.0-M2)
                       2.1.0

> Foreign keys are not properly set for ConstraintUpdateManager to determine the correct order of the sql
> -------------------------------------------------------------------------------------------------------
>
>                 Key: OPENJPA-1057
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-1057
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jdbc
>    Affects Versions: 2.1.0
>            Reporter: Fay Wang
>            Assignee: Fay Wang
>             Fix For: 2.0.0
>
>         Attachments: OPENJPA-1057.patch
>
>
> In the following situations, foreign keys are not properly set in the RowImpl for ConstraintUpdateManager to correctly determine the order of sql:
> (1) bottom-up table creation for primary table and secondary table with foreign key referencing the primary table: Both primary and secondary tables are used to store the data in an entity, which has the annotation as below:
>    @Table(name="Tbl1")   
>    @SecondaryTable(name="Tbl2",pkJoinColumns=@PrimaryKeyJoinColumn(name="ID"))   
>    public class EntityA implements Serializable {
>  
> ...
>     }
> In this situation, Openjpa fails to record the foreign key information in the secondary row. Without the foreign key constraint information, the ConstraintUpdateManager is unable to determine the ordering correctly.
> (2) bottom up table creation for an entity and its toOne/toMany relation with foreign key constraint. For example:
> create table Bidir1to1A (id integer not null, age integer not null, name varchar(30), primary key (id));
> create table Bidir1to1B (id integer not null, name varchar(30), entitya_id integer, primary key (id));
> alter table Bidir1to1B add constraint FK452ACC2BD7410520 foreign key (entitya_id) references Bidir1to1A;
> In this situation, Openjpa reads in the database foreign key constraint. If the relation field does not have ForeignKey annotation, or the ForeignKey annotation has deleteAction set to DEFAULT:
>     @OneToOne(cascade=CascadeType.REMOVE)  
>     @ForeignKey(deleteAction=ForeignKeyAction.DEFAULT)
>     public Unidir1to1B  entityb;
> this foreign key constraint will not be recorded in the RowImpl due to the deleteAction = ForeignKey.ACTION_NONE. The lack of foreign key constraint information in the RowImpl leads to the wrong ordering of the sql by the ConstraintUpdateManager.

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


[jira] Updated: (OPENJPA-1057) Foreign keys are not properly set for ConstraintUpdateManager to determine the correct order of the sql

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

Fay Wang updated OPENJPA-1057:
------------------------------

    Description: 
In the following situations, foreign keys are not properly set in the RowImpl for ConstraintUpdateManager to correctly determine the order of sql:

(1) bottom-up table creation for primary table and secondary table with foreign key referencing the primary table: Both primary and secondary tables are used to store the data in an entity, which has the annotation as below:

   @Table(name="Tbl1")   
   @SecondaryTable(name="Tbl2",pkJoinColumns=@PrimaryKeyJoinColumn(name="ID"))   
   public class EntityA implements Serializable {
 
...
    }

In this situation, Openjpa fails to record the foreign key information in the secondary row. Without the foreign key constraint information, the ConstraintUpdateManager is unable to determine the ordering correctly.

(2) bottom up table creation for an entity and its toOne/toMany relation with foreign key constraint. For example:

create table Bidir1to1A (id integer not null, age integer not null, name varchar(30), primary key (id));
create table Bidir1to1B (id integer not null, name varchar(30), entitya_id integer, primary key (id));
alter table Bidir1to1B add constraint FK452ACC2BD7410520 foreign key (entitya_id) references Bidir1to1A;

In this situation, Openjpa reads in the database foreign key constraint. However, this foreign key constraint is not recorded in the RowImpl due to the deleteAction = ForeignKey.ACTION_NONE. The lack of foreign key constraint information in the RowImpl leads to the wrong ordering of the sql by the ConstraintUpdateManager.

(3) top-down table creation with the following entity defintion:

@Entity
@Table(name="EntityA")   
public class Unidir1to1A implements IUnidir1to1A, Serializable {

    private static final long serialVersionUID = -1734942085082845941L;

    @Id
    Integer id;

    @OneToOne(cascade=CascadeType.REMOVE)  
    @ForeignKey(deleteAction=ForeignKeyAction.DEFAULT)
    public Unidir1to1B  entityb;

The deleteAction set to ForeignKeyAction.DEFAULT is translated to ForeignKey.ACTION_NONE (for DB2 at least). As in case (2) above, this leads to missing foreign key constraint in the RowImpl, resulting in wrong ordering of the sql.

Note that the wrong ordering of sql means that the sql that insert into the parent table is not executed prior to the sql that insert into the child table.

The fix is:
(1) add foreign key constraint to the RowImpl when @SecondaryTable is used
(2) record foreign key constraint regardless of ForeignKey delete action.   



















  was:ConstraintUpdateManager fails to order the update/insert/delete rows properly when @SecondaryTable is used to store the entity in different tables.

        Summary: Foreign keys are not properly set for ConstraintUpdateManager to determine the correct order of the sql  (was: ConstraintUpdateManager fails to order the update/insert/delete rows properly when @SecondaryTable is used)

> Foreign keys are not properly set for ConstraintUpdateManager to determine the correct order of the sql
> -------------------------------------------------------------------------------------------------------
>
>                 Key: OPENJPA-1057
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-1057
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jdbc
>    Affects Versions: 2.0.0
>            Reporter: Fay Wang
>            Assignee: Fay Wang
>             Fix For: 2.0.0
>
>
> In the following situations, foreign keys are not properly set in the RowImpl for ConstraintUpdateManager to correctly determine the order of sql:
> (1) bottom-up table creation for primary table and secondary table with foreign key referencing the primary table: Both primary and secondary tables are used to store the data in an entity, which has the annotation as below:
>    @Table(name="Tbl1")   
>    @SecondaryTable(name="Tbl2",pkJoinColumns=@PrimaryKeyJoinColumn(name="ID"))   
>    public class EntityA implements Serializable {
>  
> ...
>     }
> In this situation, Openjpa fails to record the foreign key information in the secondary row. Without the foreign key constraint information, the ConstraintUpdateManager is unable to determine the ordering correctly.
> (2) bottom up table creation for an entity and its toOne/toMany relation with foreign key constraint. For example:
> create table Bidir1to1A (id integer not null, age integer not null, name varchar(30), primary key (id));
> create table Bidir1to1B (id integer not null, name varchar(30), entitya_id integer, primary key (id));
> alter table Bidir1to1B add constraint FK452ACC2BD7410520 foreign key (entitya_id) references Bidir1to1A;
> In this situation, Openjpa reads in the database foreign key constraint. However, this foreign key constraint is not recorded in the RowImpl due to the deleteAction = ForeignKey.ACTION_NONE. The lack of foreign key constraint information in the RowImpl leads to the wrong ordering of the sql by the ConstraintUpdateManager.
> (3) top-down table creation with the following entity defintion:
> @Entity
> @Table(name="EntityA")   
> public class Unidir1to1A implements IUnidir1to1A, Serializable {
>     private static final long serialVersionUID = -1734942085082845941L;
>     @Id
>     Integer id;
>     @OneToOne(cascade=CascadeType.REMOVE)  
>     @ForeignKey(deleteAction=ForeignKeyAction.DEFAULT)
>     public Unidir1to1B  entityb;
> The deleteAction set to ForeignKeyAction.DEFAULT is translated to ForeignKey.ACTION_NONE (for DB2 at least). As in case (2) above, this leads to missing foreign key constraint in the RowImpl, resulting in wrong ordering of the sql.
> Note that the wrong ordering of sql means that the sql that insert into the parent table is not executed prior to the sql that insert into the child table.
> The fix is:
> (1) add foreign key constraint to the RowImpl when @SecondaryTable is used
> (2) record foreign key constraint regardless of ForeignKey delete action.   

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


[jira] Updated: (OPENJPA-1057) Foreign keys are not properly set for ConstraintUpdateManager to determine the correct order of the sql

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

Fay Wang updated OPENJPA-1057:
------------------------------

    Attachment: OPENJPA-1057.patch

> Foreign keys are not properly set for ConstraintUpdateManager to determine the correct order of the sql
> -------------------------------------------------------------------------------------------------------
>
>                 Key: OPENJPA-1057
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-1057
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jdbc
>    Affects Versions: 2.0.0
>            Reporter: Fay Wang
>            Assignee: Fay Wang
>             Fix For: 2.0.0
>
>         Attachments: OPENJPA-1057.patch
>
>
> In the following situations, foreign keys are not properly set in the RowImpl for ConstraintUpdateManager to correctly determine the order of sql:
> (1) bottom-up table creation for primary table and secondary table with foreign key referencing the primary table: Both primary and secondary tables are used to store the data in an entity, which has the annotation as below:
>    @Table(name="Tbl1")   
>    @SecondaryTable(name="Tbl2",pkJoinColumns=@PrimaryKeyJoinColumn(name="ID"))   
>    public class EntityA implements Serializable {
>  
> ...
>     }
> In this situation, Openjpa fails to record the foreign key information in the secondary row. Without the foreign key constraint information, the ConstraintUpdateManager is unable to determine the ordering correctly.
> (2) bottom up table creation for an entity and its toOne/toMany relation with foreign key constraint. For example:
> create table Bidir1to1A (id integer not null, age integer not null, name varchar(30), primary key (id));
> create table Bidir1to1B (id integer not null, name varchar(30), entitya_id integer, primary key (id));
> alter table Bidir1to1B add constraint FK452ACC2BD7410520 foreign key (entitya_id) references Bidir1to1A;
> In this situation, Openjpa reads in the database foreign key constraint. If the relation field does not have ForeignKey annotation, or the ForeignKey annotation has deleteAction set to DEFAULT:
>     @OneToOne(cascade=CascadeType.REMOVE)  
>     @ForeignKey(deleteAction=ForeignKeyAction.DEFAULT)
>     public Unidir1to1B  entityb;
> this foreign key constraint will not be recorded in the RowImpl due to the deleteAction = ForeignKey.ACTION_NONE. The lack of foreign key constraint information in the RowImpl leads to the wrong ordering of the sql by the ConstraintUpdateManager.

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


[jira] Updated: (OPENJPA-1057) Foreign keys are not properly set for ConstraintUpdateManager to determine the correct order of the sql

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

Donald Woods updated OPENJPA-1057:
----------------------------------

    Patch Info: [Patch Available]

> Foreign keys are not properly set for ConstraintUpdateManager to determine the correct order of the sql
> -------------------------------------------------------------------------------------------------------
>
>                 Key: OPENJPA-1057
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-1057
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jdbc
>    Affects Versions: 2.0.0-M2
>            Reporter: Fay Wang
>            Assignee: Fay Wang
>             Fix For: 2.0.0
>
>         Attachments: OPENJPA-1057.patch
>
>
> In the following situations, foreign keys are not properly set in the RowImpl for ConstraintUpdateManager to correctly determine the order of sql:
> (1) bottom-up table creation for primary table and secondary table with foreign key referencing the primary table: Both primary and secondary tables are used to store the data in an entity, which has the annotation as below:
>    @Table(name="Tbl1")   
>    @SecondaryTable(name="Tbl2",pkJoinColumns=@PrimaryKeyJoinColumn(name="ID"))   
>    public class EntityA implements Serializable {
>  
> ...
>     }
> In this situation, Openjpa fails to record the foreign key information in the secondary row. Without the foreign key constraint information, the ConstraintUpdateManager is unable to determine the ordering correctly.
> (2) bottom up table creation for an entity and its toOne/toMany relation with foreign key constraint. For example:
> create table Bidir1to1A (id integer not null, age integer not null, name varchar(30), primary key (id));
> create table Bidir1to1B (id integer not null, name varchar(30), entitya_id integer, primary key (id));
> alter table Bidir1to1B add constraint FK452ACC2BD7410520 foreign key (entitya_id) references Bidir1to1A;
> In this situation, Openjpa reads in the database foreign key constraint. If the relation field does not have ForeignKey annotation, or the ForeignKey annotation has deleteAction set to DEFAULT:
>     @OneToOne(cascade=CascadeType.REMOVE)  
>     @ForeignKey(deleteAction=ForeignKeyAction.DEFAULT)
>     public Unidir1to1B  entityb;
> this foreign key constraint will not be recorded in the RowImpl due to the deleteAction = ForeignKey.ACTION_NONE. The lack of foreign key constraint information in the RowImpl leads to the wrong ordering of the sql by the ConstraintUpdateManager.

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


[jira] Updated: (OPENJPA-1057) Foreign keys are not properly set for ConstraintUpdateManager to determine the correct order of the sql

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

Donald Woods updated OPENJPA-1057:
----------------------------------

    Affects Version/s:     (was: 2.1.0)
                       2.0.0-M2
        Fix Version/s:     (was: 2.0.0)
                       2.1.0

> Foreign keys are not properly set for ConstraintUpdateManager to determine the correct order of the sql
> -------------------------------------------------------------------------------------------------------
>
>                 Key: OPENJPA-1057
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-1057
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jdbc
>    Affects Versions: 2.0.0-M2
>            Reporter: Fay Wang
>            Assignee: Fay Wang
>             Fix For: 2.1.0
>
>         Attachments: OPENJPA-1057.patch
>
>
> In the following situations, foreign keys are not properly set in the RowImpl for ConstraintUpdateManager to correctly determine the order of sql:
> (1) bottom-up table creation for primary table and secondary table with foreign key referencing the primary table: Both primary and secondary tables are used to store the data in an entity, which has the annotation as below:
>    @Table(name="Tbl1")   
>    @SecondaryTable(name="Tbl2",pkJoinColumns=@PrimaryKeyJoinColumn(name="ID"))   
>    public class EntityA implements Serializable {
>  
> ...
>     }
> In this situation, Openjpa fails to record the foreign key information in the secondary row. Without the foreign key constraint information, the ConstraintUpdateManager is unable to determine the ordering correctly.
> (2) bottom up table creation for an entity and its toOne/toMany relation with foreign key constraint. For example:
> create table Bidir1to1A (id integer not null, age integer not null, name varchar(30), primary key (id));
> create table Bidir1to1B (id integer not null, name varchar(30), entitya_id integer, primary key (id));
> alter table Bidir1to1B add constraint FK452ACC2BD7410520 foreign key (entitya_id) references Bidir1to1A;
> In this situation, Openjpa reads in the database foreign key constraint. If the relation field does not have ForeignKey annotation, or the ForeignKey annotation has deleteAction set to DEFAULT:
>     @OneToOne(cascade=CascadeType.REMOVE)  
>     @ForeignKey(deleteAction=ForeignKeyAction.DEFAULT)
>     public Unidir1to1B  entityb;
> this foreign key constraint will not be recorded in the RowImpl due to the deleteAction = ForeignKey.ACTION_NONE. The lack of foreign key constraint information in the RowImpl leads to the wrong ordering of the sql by the ConstraintUpdateManager.

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


[jira] Commented: (OPENJPA-1057) Foreign keys are not properly set for ConstraintUpdateManager to determine the correct order of the sql

Posted by "Donald Woods (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OPENJPA-1057?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12843234#action_12843234 ] 

Donald Woods commented on OPENJPA-1057:
---------------------------------------

Fay, is the attached patch still valid/needed for 2.0.0?

> Foreign keys are not properly set for ConstraintUpdateManager to determine the correct order of the sql
> -------------------------------------------------------------------------------------------------------
>
>                 Key: OPENJPA-1057
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-1057
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jdbc
>    Affects Versions: 2.0.0-M2
>            Reporter: Fay Wang
>            Assignee: Fay Wang
>             Fix For: 2.0.0
>
>         Attachments: OPENJPA-1057.patch
>
>
> In the following situations, foreign keys are not properly set in the RowImpl for ConstraintUpdateManager to correctly determine the order of sql:
> (1) bottom-up table creation for primary table and secondary table with foreign key referencing the primary table: Both primary and secondary tables are used to store the data in an entity, which has the annotation as below:
>    @Table(name="Tbl1")   
>    @SecondaryTable(name="Tbl2",pkJoinColumns=@PrimaryKeyJoinColumn(name="ID"))   
>    public class EntityA implements Serializable {
>  
> ...
>     }
> In this situation, Openjpa fails to record the foreign key information in the secondary row. Without the foreign key constraint information, the ConstraintUpdateManager is unable to determine the ordering correctly.
> (2) bottom up table creation for an entity and its toOne/toMany relation with foreign key constraint. For example:
> create table Bidir1to1A (id integer not null, age integer not null, name varchar(30), primary key (id));
> create table Bidir1to1B (id integer not null, name varchar(30), entitya_id integer, primary key (id));
> alter table Bidir1to1B add constraint FK452ACC2BD7410520 foreign key (entitya_id) references Bidir1to1A;
> In this situation, Openjpa reads in the database foreign key constraint. If the relation field does not have ForeignKey annotation, or the ForeignKey annotation has deleteAction set to DEFAULT:
>     @OneToOne(cascade=CascadeType.REMOVE)  
>     @ForeignKey(deleteAction=ForeignKeyAction.DEFAULT)
>     public Unidir1to1B  entityb;
> this foreign key constraint will not be recorded in the RowImpl due to the deleteAction = ForeignKey.ACTION_NONE. The lack of foreign key constraint information in the RowImpl leads to the wrong ordering of the sql by the ConstraintUpdateManager.

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