You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by "Jeremy Bauer (JIRA)" <ji...@apache.org> on 2008/07/29 23:07:31 UTC

[jira] Created: (OPENJPA-670) Discriminator column is missing from table when inheritance is used without annotation

Discriminator column is missing from table when inheritance is used without annotation
--------------------------------------------------------------------------------------

                 Key: OPENJPA-670
                 URL: https://issues.apache.org/jira/browse/OPENJPA-670
             Project: OpenJPA
          Issue Type: Bug
          Components: jdbc
    Affects Versions: 1.2.0, 1.3.0
            Reporter: Jeremy Bauer


According to the EJB 3.0 JPA spec (pp. 191, section 9.1.29):

"If the Inheritance annotation is not specified or if no inheritance type is specified for an entity class
hierarchy, the SINGLE_TABLE mapping strategy is used."

I've found that if an entity inheritance hierarchy is specified without an explicit DiscriminatorColumn or Inheritance annotation, a single table will be used for mapping, but there will be no discriminator column in the table.  

pp. 191 - 192, section 9.1.30 of the spec reads:

"For the SINGLE_TABLE mapping strategy, and typically also for the JOINED strategy, the persistence
provider will use a type discriminator column."

and

"If the DiscriminatorColumn annotation is missing, and a discriminator column is required, the
name of the discriminator column defaults to "DTYPE" and the discriminator type to STRING."

Without a discriminator column a scenario such as:

entity B extends entity A
entity C extends entity A

"select c from C"  will return entities of type A, B, and C (which is a data integrity issue) because there is no way to distinguish between the entity types.

The simple workaround is to specify an @Inheritance or @DiscriminatorColumn annotation on the root class, but OpenJPA should exhibit default behavior defined by the spec when these annotations are not specified.

I have a patch and jUnits in the works and will post them shortly.


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


[jira] Resolved: (OPENJPA-670) Discriminator column is missing from table when inheritance is used without annotation

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

Michael Dick resolved OPENJPA-670.
----------------------------------

    Resolution: Fixed
      Assignee: Jeremy Bauer

Fixed in trunk and 1.2.x

> Discriminator column is missing from table when inheritance is used without annotation
> --------------------------------------------------------------------------------------
>
>                 Key: OPENJPA-670
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-670
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jdbc
>    Affects Versions: 1.2.0, 1.3.0
>            Reporter: Jeremy Bauer
>            Assignee: Jeremy Bauer
>             Fix For: 1.2.0, 1.3.0
>
>         Attachments: openjpa-670.patch
>
>
> According to the EJB 3.0 JPA spec (pp. 191, section 9.1.29):
> "If the Inheritance annotation is not specified or if no inheritance type is specified for an entity class
> hierarchy, the SINGLE_TABLE mapping strategy is used."
> I've found that if an entity inheritance hierarchy is specified without an explicit DiscriminatorColumn or Inheritance annotation, a single table will be used for mapping, but there will be no discriminator column in the table.  
> pp. 191 - 192, section 9.1.30 of the spec reads:
> "For the SINGLE_TABLE mapping strategy, and typically also for the JOINED strategy, the persistence
> provider will use a type discriminator column."
> and
> "If the DiscriminatorColumn annotation is missing, and a discriminator column is required, the
> name of the discriminator column defaults to "DTYPE" and the discriminator type to STRING."
> Without a discriminator column a scenario such as:
> entity B extends entity A
> entity C extends entity A
> "select c from C"  will return entities of type A, B, and C (which is a data integrity issue) because there is no way to distinguish between the entity types.
> The simple workaround is to specify an @Inheritance or @DiscriminatorColumn annotation on the root class, but OpenJPA should exhibit default behavior defined by the spec when these annotations are not specified.
> I have a patch and jUnits in the works and will post them shortly.

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


[jira] Updated: (OPENJPA-670) Discriminator column is missing from table when inheritance is used without annotation

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

Michael Dick updated OPENJPA-670:
---------------------------------

    Fix Version/s: 1.3.0
                   1.2.0

> Discriminator column is missing from table when inheritance is used without annotation
> --------------------------------------------------------------------------------------
>
>                 Key: OPENJPA-670
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-670
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jdbc
>    Affects Versions: 1.2.0, 1.3.0
>            Reporter: Jeremy Bauer
>             Fix For: 1.2.0, 1.3.0
>
>         Attachments: openjpa-670.patch
>
>
> According to the EJB 3.0 JPA spec (pp. 191, section 9.1.29):
> "If the Inheritance annotation is not specified or if no inheritance type is specified for an entity class
> hierarchy, the SINGLE_TABLE mapping strategy is used."
> I've found that if an entity inheritance hierarchy is specified without an explicit DiscriminatorColumn or Inheritance annotation, a single table will be used for mapping, but there will be no discriminator column in the table.  
> pp. 191 - 192, section 9.1.30 of the spec reads:
> "For the SINGLE_TABLE mapping strategy, and typically also for the JOINED strategy, the persistence
> provider will use a type discriminator column."
> and
> "If the DiscriminatorColumn annotation is missing, and a discriminator column is required, the
> name of the discriminator column defaults to "DTYPE" and the discriminator type to STRING."
> Without a discriminator column a scenario such as:
> entity B extends entity A
> entity C extends entity A
> "select c from C"  will return entities of type A, B, and C (which is a data integrity issue) because there is no way to distinguish between the entity types.
> The simple workaround is to specify an @Inheritance or @DiscriminatorColumn annotation on the root class, but OpenJPA should exhibit default behavior defined by the spec when these annotations are not specified.
> I have a patch and jUnits in the works and will post them shortly.

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


[jira] Updated: (OPENJPA-670) Discriminator column is missing from table when inheritance is used without annotation

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

Jeremy Bauer updated OPENJPA-670:
---------------------------------

    Attachment: openjpa-670.patch

Attaching patch containing fix and jUnits for trunk (currently 1.3.0).  Please review and if no comments, commit for trunk and 1.2.x.

In case it isn't clear from the code and comments, the update to PersistenceTestCase is to clean up tables used by managed interfaces.  They are by definition abstract and were being skipped during the cleanup process.



> Discriminator column is missing from table when inheritance is used without annotation
> --------------------------------------------------------------------------------------
>
>                 Key: OPENJPA-670
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-670
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jdbc
>    Affects Versions: 1.2.0, 1.3.0
>            Reporter: Jeremy Bauer
>         Attachments: openjpa-670.patch
>
>
> According to the EJB 3.0 JPA spec (pp. 191, section 9.1.29):
> "If the Inheritance annotation is not specified or if no inheritance type is specified for an entity class
> hierarchy, the SINGLE_TABLE mapping strategy is used."
> I've found that if an entity inheritance hierarchy is specified without an explicit DiscriminatorColumn or Inheritance annotation, a single table will be used for mapping, but there will be no discriminator column in the table.  
> pp. 191 - 192, section 9.1.30 of the spec reads:
> "For the SINGLE_TABLE mapping strategy, and typically also for the JOINED strategy, the persistence
> provider will use a type discriminator column."
> and
> "If the DiscriminatorColumn annotation is missing, and a discriminator column is required, the
> name of the discriminator column defaults to "DTYPE" and the discriminator type to STRING."
> Without a discriminator column a scenario such as:
> entity B extends entity A
> entity C extends entity A
> "select c from C"  will return entities of type A, B, and C (which is a data integrity issue) because there is no way to distinguish between the entity types.
> The simple workaround is to specify an @Inheritance or @DiscriminatorColumn annotation on the root class, but OpenJPA should exhibit default behavior defined by the spec when these annotations are not specified.
> I have a patch and jUnits in the works and will post them shortly.

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