Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 317448 - JPA forward mapper fails to create join table
Summary: JPA forward mapper fails to create join table
Status: CLOSED DUPLICATE of bug 317597
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows Vista
: P2 normal (vote)
Target Milestone: ---   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 317597
Blocks:
  Show dependency tree
 
Reported: 2010-06-21 10:13 EDT by Adrian Goerler CLA
Modified: 2022-06-09 10:35 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 Adrian Goerler CLA 2010-06-21 10:13:13 EDT
In the test model "jpa1testmodel" of the test suite eclipselink.jpa.wdf.test,
there is an entity
org.eclipse.persistence.testing.models.wdf.jpa1.employee.Vehicle. Vehicle has a
many-to-many relationship with the entity
org.eclipse.persistence.testing.models.wdf.jpa1.employee.TravelProfile. This
relationship is mapped through a join table "TMP_VEHICLE_PROFILE".
EclipseLink's forward mapper fails to create this join table.
Comment 1 Guy Pelletier CLA 2010-07-06 10:24:53 EDT
I just tried your model classes (Vehicle and TravelProfile) in our DDL test model and observed the following table creation:

CREATE TABLE TMP_VEHICLE_PROFILE (VEHICLE_ID NUMBER(5) NOT NULL, PROFILE_ID BLOB NOT NULL, PRIMARY KEY (VEHICLE_ID, PROFILE_ID))

My persistence.xml has the following properties:

<property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
<property name="eclipselink.ddl-generation.output-mode" value="both"/>

<property name="eclipselink.create-ddl-jdbc-file-name" value="createDDL_ddlGeneration.jdbc"/>

<property name="eclipselink.drop-ddl-jdbc-file-name" value="dropDDL_ddlGeneration.jdbc"/>

Am I missing something?
Comment 2 Adrian Goerler CLA 2010-07-08 07:19:24 EDT
The CREATE TABLE statement created by the forward mapper can't be executed on MySQL:

Call: DROP TABLE TMP_VEHICLE_PROFILE
Query: DataModifyQuery(sql="DROP TABLE TMP_VEHICLE_PROFILE")
[EL Finest]: 2010-07-08 13:07:30.937--ServerSession(33219526)--Thread(Thread[main,5,main])--Execute query DataModifyQuery(sql="CREATE TABLE TMP_VEHICLE_PROFILE (PROFILE_ID LONGBLOB NOT NULL, VEHICLE_ID SMALLINT NOT NULL, PRIMARY KEY (PROFILE_ID, VEHICLE_ID))")
[EL Fine]: 2010-07-08 13:07:30.937--ServerSession(33219526)--Connection(1309073)--Thread(Thread[main,5,main])--CREATE TABLE TMP_VEHICLE_PROFILE (PROFILE_ID LONGBLOB NOT NULL, VEHICLE_ID SMALLINT NOT NULL, PRIMARY KEY (PROFILE_ID, VEHICLE_ID))
[EL Fine]: 2010-07-08 13:07:30.937--ServerSession(33219526)--Thread(Thread[main,5,main])--SELECT 1
[EL Warning]: 2010-07-08 13:07:30.937--ServerSession(33219526)--Thread(Thread[main,5,main])--Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.2.0.qualifier): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: BLOB/TEXT column 'PROFILE_ID' used in key specification without a key length

The reason is that EclipseLink chooses "LONGBLOB" as the column type.

The the id "guid" of the related entity TravelProfile, from which the column type in the join table is derived, is annotated as follows:

    @Id
    @Column(length = 16)
    public byte[] getGuid() {
        return guid;
    }

As this attribute is not anntotated with @Lob, a column with BINARY or VARBINARY type should be created instead.
Comment 3 Guy Pelletier CLA 2010-07-16 09:44:13 EDT
Ok, I understand now. Is this bug not a duplicate of 317597 then?

Also 317597 is currently targetted for 2.2 and this one for 2.1.1. I think this should be closed as a duplicate of 317597 since it is just another side of effect of bug 317597.

Agree?
Comment 4 Adrian Goerler CLA 2010-07-16 09:46:35 EDT
(In reply to comment #3)
> Ok, I understand now. Is this bug not a duplicate of 317597 then?
> 
> Also 317597 is currently targetted for 2.2 and this one for 2.1.1. I think this
> should be closed as a duplicate of 317597 since it is just another side of
> effect of bug 317597.
> 
> Agree?

Agree.

*** This bug has been marked as a duplicate of bug 317597 ***
Comment 5 Eclipse Webmaster CLA 2022-06-09 10:35:29 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink