case mismatch in foreign key generation - querydsl-sql-codegen-3.3.2.jar #683

Closed
emazv72 opened this Issue Mar 24, 2014 · 14 comments

Comments

Projects
None yet
2 participants
@emazv72

emazv72 commented Mar 24, 2014

When generating classes with the following code:

String pkg ="it.next.catol.model";
MetaDataExporter exporter = new MetaDataExporter(); 
exporter.setSchemaPattern("catol");
exporter.setPackageName(pkg);
exporter.setTargetFolder(new File("src"));
exporter.export(conn.getMetaData());

it generates the following code:

public final StringPath mProductBomId = createString("mProductBomId");
...
public final com.mysema.query.sql.ForeignKey<QMProduct> mproductBomproduct = createForeignKey(mProductbomId, "M_PRODUCT_ID");
...

There's a mismatch in the variable casing: mProductbomId should be mProductBomId.

DB : MySQL 5.6.16
JDBC Driver : mysql-connector-java-5.1.21

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Mar 24, 2014

Member

What is the column name for mProductBomId ?

Member

timowest commented Mar 24, 2014

What is the column name for mProductBomId ?

@emazv72

This comment has been minimized.

Show comment
Hide comment
@emazv72

emazv72 Mar 24, 2014

it's M_PRODUCT_BOM_ID varchar(40)

emazv72 commented Mar 24, 2014

it's M_PRODUCT_BOM_ID varchar(40)

timowest added a commit that referenced this issue Mar 24, 2014

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Mar 24, 2014

Member

@emazv72 Could you try again with the latest SNAPSHOT from here https://oss.sonatype.org/content/repositories/snapshots/

Member

timowest commented Mar 24, 2014

@emazv72 Could you try again with the latest SNAPSHOT from here https://oss.sonatype.org/content/repositories/snapshots/

@timowest timowest added the bug label Mar 24, 2014

@emazv72

This comment has been minimized.

Show comment
Hide comment
@emazv72

emazv72 Mar 24, 2014

Switched to version 3.3.3.BUILD-SNAPSHOT from repository and regenerated, but the problem is still there.
I have about 500 tables with PK field names as __ID, but this was the only one with troubles.

emazv72 commented Mar 24, 2014

Switched to version 3.3.3.BUILD-SNAPSHOT from repository and regenerated, but the problem is still there.
I have about 500 tables with PK field names as __ID, but this was the only one with troubles.

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Mar 25, 2014

Member

Could you show me how the foreign key constraint definition looks like?

Member

timowest commented Mar 25, 2014

Could you show me how the foreign key constraint definition looks like?

@emazv72

This comment has been minimized.

Show comment
Hide comment
@emazv72

emazv72 Mar 25, 2014

This is the DDL used to generate the table.
The foreign key constraint is MPRODUCT_BOMPRODUCT

CREATE TABLE
m_product_bom
(
M_PRODUCT_BOM_ID VARCHAR(40) NOT NULL,
AD_CLIENT_ID VARCHAR(40) NOT NULL,
AD_ORG_ID VARCHAR(40) NOT NULL,
ISACTIVE CHAR(1) DEFAULT 'Y' NOT NULL,
CREATED TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
CREATEDBY VARCHAR(40) NOT NULL,
UPDATED TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
UPDATEDBY VARCHAR(40) NOT NULL,
LINE DECIMAL NOT NULL,
M_PRODUCT_ID VARCHAR(40) NOT NULL,
M_PRODUCTBOM_ID VARCHAR(40) NOT NULL,
BOMQTY DECIMAL(20,2) DEFAULT '0.00' NOT NULL,
DESCRIPTION VARCHAR(510),
BOMTYPE CHAR(1),
PRIMARY KEY (M_PRODUCT_BOM_ID),
CONSTRAINT MPRODUCT_BOMPRODUCT FOREIGN KEY (M_PRODUCTBOM_ID) REFERENCES m_product
(M_PRODUCT_ID) ON
DELETE
NO ACTION
ON
UPDATE
NO ACTION,
CONSTRAINT MPRODUCT_MPRODUCTBOM FOREIGN KEY (M_PRODUCT_ID) REFERENCES m_product
(M_PRODUCT_ID)
ON
DELETE
NO ACTION
ON
UPDATE
NO ACTION,
INDEX MPRODUCT_MPRODUCTBOM (M_PRODUCT_ID),
INDEX MPRODUCT_BOMPRODUCT (M_PRODUCTBOM_ID)
)
ENGINE=InnoDB DEFAULT CHARSET=latin1;

emazv72 commented Mar 25, 2014

This is the DDL used to generate the table.
The foreign key constraint is MPRODUCT_BOMPRODUCT

CREATE TABLE
m_product_bom
(
M_PRODUCT_BOM_ID VARCHAR(40) NOT NULL,
AD_CLIENT_ID VARCHAR(40) NOT NULL,
AD_ORG_ID VARCHAR(40) NOT NULL,
ISACTIVE CHAR(1) DEFAULT 'Y' NOT NULL,
CREATED TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
CREATEDBY VARCHAR(40) NOT NULL,
UPDATED TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
UPDATEDBY VARCHAR(40) NOT NULL,
LINE DECIMAL NOT NULL,
M_PRODUCT_ID VARCHAR(40) NOT NULL,
M_PRODUCTBOM_ID VARCHAR(40) NOT NULL,
BOMQTY DECIMAL(20,2) DEFAULT '0.00' NOT NULL,
DESCRIPTION VARCHAR(510),
BOMTYPE CHAR(1),
PRIMARY KEY (M_PRODUCT_BOM_ID),
CONSTRAINT MPRODUCT_BOMPRODUCT FOREIGN KEY (M_PRODUCTBOM_ID) REFERENCES m_product
(M_PRODUCT_ID) ON
DELETE
NO ACTION
ON
UPDATE
NO ACTION,
CONSTRAINT MPRODUCT_MPRODUCTBOM FOREIGN KEY (M_PRODUCT_ID) REFERENCES m_product
(M_PRODUCT_ID)
ON
DELETE
NO ACTION
ON
UPDATE
NO ACTION,
INDEX MPRODUCT_MPRODUCTBOM (M_PRODUCT_ID),
INDEX MPRODUCT_BOMPRODUCT (M_PRODUCTBOM_ID)
)
ENGINE=InnoDB DEFAULT CHARSET=latin1;

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Mar 25, 2014

Member

And how does the generated class look like?

IMHO M_PRODUCTBOM_ID is correctly transformed into mProductbomId

Member

timowest commented Mar 25, 2014

And how does the generated class look like?

IMHO M_PRODUCTBOM_ID is correctly transformed into mProductbomId

@emazv72

This comment has been minimized.

Show comment
Hide comment
@emazv72

emazv72 Mar 25, 2014

This is the generated source

package it.next.catol.model;

import static com.mysema.query.types.PathMetadataFactory.*;

import com.mysema.query.types.path.*;

import com.mysema.query.types.PathMetadata;
import javax.annotation.Generated;
import com.mysema.query.types.Path;

import com.mysema.query.sql.ColumnMetadata;

/**

  • QMProductBom is a Querydsl query type for MProductBom
    */
    @generated("com.mysema.query.sql.codegen.MetaDataSerializer")
    public class QMProductBom extends com.mysema.query.sql.RelationalPathBase {

    private static final long serialVersionUID = 1533643302;

    public static final QMProductBom mProductBom = new QMProductBom("m_product_bom");

    public final StringPath adClientId = createString("adClientId");

    public final StringPath adOrgId = createString("adOrgId");

    public final NumberPath<java.math.BigDecimal> bomqty = createNumber("bomqty", java.math.BigDecimal.class);

    public final StringPath bomtype = createString("bomtype");

    public final DateTimePath<java.sql.Timestamp> created = createDateTime("created", java.sql.Timestamp.class);

    public final StringPath createdby = createString("createdby");

    public final StringPath description = createString("description");

    public final StringPath isactive = createString("isactive");

    public final NumberPath line = createNumber("line", Long.class);

    public final StringPath mProductBomId = createString("mProductBomId");

    public final StringPath mProductId = createString("mProductId");

    public final DateTimePath<java.sql.Timestamp> updated = createDateTime("updated", java.sql.Timestamp.class);

    public final StringPath updatedby = createString("updatedby");

    public final com.mysema.query.sql.PrimaryKey primary = createPrimaryKey(mProductBomId);

    public final com.mysema.query.sql.ForeignKey mproductMproductbom = createForeignKey(mProductId, "M_PRODUCT_ID");

    public final com.mysema.query.sql.ForeignKey mproductBomproduct = createForeignKey(mProductbomId, "M_PRODUCT_ID");

    public QMProductBom(String variable) {
    super(MProductBom.class, forVariable(variable), "null", "m_product_bom");
    addMetadata();
    }

    public QMProductBom(String variable, String schema, String table) {
    super(MProductBom.class, forVariable(variable), schema, table);
    addMetadata();
    }

    public QMProductBom(Path<? extends MProductBom> path) {
    super(path.getType(), path.getMetadata(), "null", "m_product_bom");
    addMetadata();
    }

    public QMProductBom(PathMetadata<?> metadata) {
    super(MProductBom.class, metadata, "null", "m_product_bom");
    addMetadata();
    }

    public void addMetadata() {
    addMetadata(adClientId, ColumnMetadata.named("AD_CLIENT_ID").ofType(12).withSize(40).notNull());
    addMetadata(adOrgId, ColumnMetadata.named("AD_ORG_ID").ofType(12).withSize(40).notNull());
    addMetadata(bomqty, ColumnMetadata.named("BOMQTY").ofType(3).withSize(20).withDigits(2).notNull());
    addMetadata(bomtype, ColumnMetadata.named("BOMTYPE").ofType(1).withSize(1));
    addMetadata(created, ColumnMetadata.named("CREATED").ofType(93).withSize(19).notNull());
    addMetadata(createdby, ColumnMetadata.named("CREATEDBY").ofType(12).withSize(40).notNull());
    addMetadata(description, ColumnMetadata.named("DESCRIPTION").ofType(12).withSize(510));
    addMetadata(isactive, ColumnMetadata.named("ISACTIVE").ofType(1).withSize(1).notNull());
    addMetadata(line, ColumnMetadata.named("LINE").ofType(3).withSize(10).notNull());
    addMetadata(mProductBomId, ColumnMetadata.named("M_PRODUCT_BOM_ID").ofType(12).withSize(40).notNull());
    addMetadata(mProductId, ColumnMetadata.named("M_PRODUCT_ID").ofType(12).withSize(40).notNull());
    addMetadata(updated, ColumnMetadata.named("UPDATED").ofType(93).withSize(19).notNull());
    addMetadata(updatedby, ColumnMetadata.named("UPDATEDBY").ofType(12).withSize(40).notNull());
    }

}

emazv72 commented Mar 25, 2014

This is the generated source

package it.next.catol.model;

import static com.mysema.query.types.PathMetadataFactory.*;

import com.mysema.query.types.path.*;

import com.mysema.query.types.PathMetadata;
import javax.annotation.Generated;
import com.mysema.query.types.Path;

import com.mysema.query.sql.ColumnMetadata;

/**

  • QMProductBom is a Querydsl query type for MProductBom
    */
    @generated("com.mysema.query.sql.codegen.MetaDataSerializer")
    public class QMProductBom extends com.mysema.query.sql.RelationalPathBase {

    private static final long serialVersionUID = 1533643302;

    public static final QMProductBom mProductBom = new QMProductBom("m_product_bom");

    public final StringPath adClientId = createString("adClientId");

    public final StringPath adOrgId = createString("adOrgId");

    public final NumberPath<java.math.BigDecimal> bomqty = createNumber("bomqty", java.math.BigDecimal.class);

    public final StringPath bomtype = createString("bomtype");

    public final DateTimePath<java.sql.Timestamp> created = createDateTime("created", java.sql.Timestamp.class);

    public final StringPath createdby = createString("createdby");

    public final StringPath description = createString("description");

    public final StringPath isactive = createString("isactive");

    public final NumberPath line = createNumber("line", Long.class);

    public final StringPath mProductBomId = createString("mProductBomId");

    public final StringPath mProductId = createString("mProductId");

    public final DateTimePath<java.sql.Timestamp> updated = createDateTime("updated", java.sql.Timestamp.class);

    public final StringPath updatedby = createString("updatedby");

    public final com.mysema.query.sql.PrimaryKey primary = createPrimaryKey(mProductBomId);

    public final com.mysema.query.sql.ForeignKey mproductMproductbom = createForeignKey(mProductId, "M_PRODUCT_ID");

    public final com.mysema.query.sql.ForeignKey mproductBomproduct = createForeignKey(mProductbomId, "M_PRODUCT_ID");

    public QMProductBom(String variable) {
    super(MProductBom.class, forVariable(variable), "null", "m_product_bom");
    addMetadata();
    }

    public QMProductBom(String variable, String schema, String table) {
    super(MProductBom.class, forVariable(variable), schema, table);
    addMetadata();
    }

    public QMProductBom(Path<? extends MProductBom> path) {
    super(path.getType(), path.getMetadata(), "null", "m_product_bom");
    addMetadata();
    }

    public QMProductBom(PathMetadata<?> metadata) {
    super(MProductBom.class, metadata, "null", "m_product_bom");
    addMetadata();
    }

    public void addMetadata() {
    addMetadata(adClientId, ColumnMetadata.named("AD_CLIENT_ID").ofType(12).withSize(40).notNull());
    addMetadata(adOrgId, ColumnMetadata.named("AD_ORG_ID").ofType(12).withSize(40).notNull());
    addMetadata(bomqty, ColumnMetadata.named("BOMQTY").ofType(3).withSize(20).withDigits(2).notNull());
    addMetadata(bomtype, ColumnMetadata.named("BOMTYPE").ofType(1).withSize(1));
    addMetadata(created, ColumnMetadata.named("CREATED").ofType(93).withSize(19).notNull());
    addMetadata(createdby, ColumnMetadata.named("CREATEDBY").ofType(12).withSize(40).notNull());
    addMetadata(description, ColumnMetadata.named("DESCRIPTION").ofType(12).withSize(510));
    addMetadata(isactive, ColumnMetadata.named("ISACTIVE").ofType(1).withSize(1).notNull());
    addMetadata(line, ColumnMetadata.named("LINE").ofType(3).withSize(10).notNull());
    addMetadata(mProductBomId, ColumnMetadata.named("M_PRODUCT_BOM_ID").ofType(12).withSize(40).notNull());
    addMetadata(mProductId, ColumnMetadata.named("M_PRODUCT_ID").ofType(12).withSize(40).notNull());
    addMetadata(updated, ColumnMetadata.named("UPDATED").ofType(93).withSize(19).notNull());
    addMetadata(updatedby, ColumnMetadata.named("UPDATEDBY").ofType(12).withSize(40).notNull());
    }

}

timowest added a commit that referenced this issue Mar 25, 2014

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Mar 25, 2014

Member

Could you try again with the latest SNAPSHOT ?

Member

timowest commented Mar 25, 2014

Could you try again with the latest SNAPSHOT ?

@timowest timowest added the fixed label Mar 25, 2014

@emazv72

This comment has been minimized.

Show comment
Hide comment
@emazv72

emazv72 Mar 25, 2014

Works fine, thank you.

emazv72 commented Mar 25, 2014

Works fine, thank you.

@emazv72 emazv72 closed this Mar 25, 2014

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Mar 25, 2014

Member

I'll close it when it's released

Member

timowest commented Mar 25, 2014

I'll close it when it's released

@timowest timowest reopened this Mar 25, 2014

@emazv72

This comment has been minimized.

Show comment
Hide comment
@emazv72

emazv72 Mar 25, 2014

My bad, I'm a newbie on github.

emazv72 commented Mar 25, 2014

My bad, I'm a newbie on github.

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Mar 25, 2014

Member

It's not really a general github practice, but for Querydsl this is the way to track which fixes are still unreleased.

Member

timowest commented Mar 25, 2014

It's not really a general github practice, but for Querydsl this is the way to track which fixes are still unreleased.

@timowest timowest modified the milestone: 3.3.3 Apr 13, 2014

@timowest timowest modified the milestone: 3.3.3 Apr 30, 2014

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest May 2, 2014

Member

Released in 3.3.3

Member

timowest commented May 2, 2014

Released in 3.3.3

@timowest timowest closed this May 2, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment