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

[jira] Created: (OPENJPA-1059) Unnecessary creation of OPENJPA_SEQUENCE_TABLE for embeddable classes

Unnecessary creation of OPENJPA_SEQUENCE_TABLE for embeddable classes
---------------------------------------------------------------------

                 Key: OPENJPA-1059
                 URL: https://issues.apache.org/jira/browse/OPENJPA-1059
             Project: OpenJPA
          Issue Type: Bug
          Components: jdbc
    Affects Versions: 1.2.1, 2.0.0
            Reporter: Martin Dirichs
            Priority: Minor


Using OpenJPA with all identity values generated by the datastore does not
trigger the creation of OPENJPA_SEQUENCE_TABLE. However, as soon as a
embeddable class is used, this table is being created although embeddable
classes do not have a persistent identity on their own.

Example
=======
MainEntity.java:
import javax.persistence.*;

@Entity
public class MainEntity {
    @Id @GeneratedValue(strategy = GenerationType.IDENTITY)
    int id;

    @Embedded
    EmbeddedClass e; // Referencing the embedded class yields the bug
}


EmbeddedClass:
import javax.persistence.*;

@Embeddable
public class EmbeddedClass {

    String someValue;
}


META-INF/persistence.xml:
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    version="1.0">
    <persistence-unit name="showcase">
        <class>MainEntity</class>
        <class>EmbeddedClass</class>
    </persistence-unit>
</persistence>


Running org.apache.openjpa.jdbc.meta.MappingTool for the above
two classes results in the creation of OPENJPA_SEQUENCE_TABLE.
This is not the case if the reference to the embedded class is removed
from MainEntity.

According to Micheal Dick, there might be some use case where this
behaviour is desired. However, since the sequence table is used to
generate id values and embeddable classes have no id fields at all,
it seems more likely to be a bug. See here for the mailing list discussion:
http://n2.nabble.com/OPENJPA_SEQUENCE_TABLE-created-unnecessarily-for-embeddable-classes-tc2787226.html



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