Bug 298290 - JPA: Derby DDL generation for multi-level EmbeddedId attributes fails on single serialized BLOB field instead composite PK keys
Summary: JPA: Derby DDL generation for multi-level EmbeddedId attributes fails on sing...
Status: NEW
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard: derby
Keywords:
Depends on: 300626
Blocks:
  Show dependency tree
 
Reported: 2009-12-21 06:17 EST by Michael OBrien CLA
Modified: 2022-06-09 10:10 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael OBrien CLA 2009-12-21 06:17:22 EST
>We have the following multi-level EmbeddedId in the hierarchy of the entity "Project" that has a composite EmbeddedId/MapsId 
 where the EmbeddedId has its' own Embedded DeptId and the MapsId has its' own EmbeddedId DeptId.
>The issue is that DDL generation creates a BLOB instead of a proper composite ID SQL create statement.
Generated:
CREATE TABLE PROJECT (NAME VARCHAR(255) NOT NULL, START_DATE DATE, END_DATE DATE, DEPT_DEPT BLOB(2147483647) NOT NULL, PRIMARY KEY (NAME, DEPT_DEPT));

CREATE TABLE DEPARTMENT (DEPT BLOB(2147483647) NOT NULL, NAME VARCHAR(255), PRIMARY KEY (DEPT))


Manual Reference (working):
CREATE TABLE PROJECT (START_DATE DATE, END_DATE DATE, P_NAME VARCHAR(255) NOT NULL, DEPT_NUM INTEGER NOT NULL, DEPT_CTRY VARCHAR(255) NOT NULL, PRIMARY KEY (P_NAME, DEPT_NUM, DEPT_CTRY));
CREATE TABLE DEPARTMENT (NAME VARCHAR(255), NUM INTEGER NOT NULL, CTRY VARCHAR(255) NOT NULL, PRIMARY KEY (NUM, CTRY));

>Object Model
Project
  +----ProjectId (EmbeddedId)
          +----DeptId (as Embedded)
  +----Department (MapsId)
          +----DeptId (as EmbeddedId)


@Entity
public class Project {
    @EmbeddedId 
    private ProjectId id;
    
    @MapsId("dept")
    @ManyToOne
    @JoinColumns({-
            @JoinColumn(name="DEPT_NUM", referencedColumnName="NUM"),
             @JoinColumn(name="DEPT_CTRY", referencedColumnName="CTRY")})
     private Department dept;
}

@Embeddable
public class ProjectId implements Serializable {
    @Column(name="P_NAME")
    private String name;

>persistence.xml property
<property name="eclipselink.target-database" value="org.eclipse.persistence.platform.database.DerbyPlatform"/>


    @Embedded
    private DeptId dept;
}

@Entity
public class Department {
    @EmbeddedId 
    private DeptId id;
}

@Embeddable
public class DeptId implements Serializable {
    @Column(name="NUM")
    private int number;
    @Column(name="CTRY")    
    private String country;
}
Comment 1 Michael OBrien CLA 2009-12-21 06:23:53 EST
>SQL Exception on Derby 10.5.3.0 for generated SQL
      [sql] Failed to execute:  CREATE TABLE DEPARTMENT (DEPT BLOB(2147483647) NOT NULL, NAME VARCHAR(255), PRIMARY KEY (DEPT))
      [sql] java.sql.SQLException: Columns of type 'BLOB' may not be used in CREATE INDEX, ORDER BY, GROUP BY, UNION, INTERSECT, EXCEPT or DISTINCT statements because comparisons are not supported for that type.
      [sql] Failed to execute:   CREATE TABLE PROJECT (NAME VARCHAR(255) NOT NULL, START_DATE DATE, END_DATE DATE, DEPT_DEPT BLOB(2147483647) NOT NULL, PRIMARY KEY (NAME, DEPT_DEPT))
      [sql] java.sql.SQLException: Columns of type 'BLOB' may not be used in CREATE INDEX, ORDER BY, GROUP BY, UNION, INTERSECT, EXCEPT or DISTINCT statements because comparisons are not supported for that type.
Comment 2 Michael OBrien CLA 2010-01-14 10:41:08 EST
>see additional DDL gen on Derby issue in bug# 283508 - for tracking referencev
Comment 3 Tom Ware CLA 2010-01-14 15:37:40 EST
Setting target and priority.  See
http://wiki.eclipse.org/EclipseLink/Development/Bugs/Guidelines for details of
what these values mean.
Comment 4 Michael OBrien CLA 2011-01-27 11:34:41 EST
>retest on Derby 10.6
>see update for new Pagination and Sequencing support for Derby 10.6 - 10.7 submitted in bug# 323897 and bug# 335464
Comment 5 Eclipse Webmaster CLA 2022-06-09 10:10:55 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink