Community
Participate
Working Groups
>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; }
>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.
>see additional DDL gen on Derby issue in bug# 283508 - for tracking referencev
Setting target and priority. See http://wiki.eclipse.org/EclipseLink/Development/Bugs/Guidelines for details of what these values mean.
>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
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink