Codegen with no Prefix Overwrites Bean Files

Bug #704638 reported by rrmckinley on 2011-01-18
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Querydsl
Fix Released
Medium
Timo Westkämper

Bug Description

If codegen is run with empty string as a prefix then the bean and the "Q" class will have the same file name. Please consider separate table-model-prefix, table-model-suffix, bean-prefix, bean-suffix and independent bean-package settings to help the generated code fit a wide range of naming and package styles.

Alternately, it might be easier for just two settings that are templates for table model and bean, "org.my.db.sales.Q{0}" and "org.my.db.sales.beans.{0}Bean". Those patterns could be parsed to get the package names and the class name from the NamingStrategy could be applied in place of "{0}" or similar placeholder.

MetaDataExporter.java

    private void handleTable(DatabaseMetaData md, ResultSet tables) throws SQLException {
        String tableName = tables.getString(TABLE_NAME);
        String className = namingStrategy.getClassName(namePrefix, tableName);
        if (beanSerializer != null){
            className = className.substring(namePrefix.length());
        }
        EntityType classModel = createEntityType(tableName, className);
    ...
    }

Thanks for the bug report.

These are good additions, but I will take them on the roadmap after the 2.1.0 release.

Changed in querydsl:
importance: Undecided → Medium
assignee: nobody → Timo Westkämper (timo-westkamper)

Will be implemented namePrefix + nameSuffix + beanPrefix + beanSuffix, since this is more compatible with the rest of Querydsl

Changed in querydsl:
status: New → In Progress

I just added the following properties namePrefix + nameSuffix + beanPrefix + beanSuffix + beanPackageName to MetaDataExporter. McKinley, could you make sure that the changes work for you?

Changed in querydsl:
status: In Progress → Fix Committed

McKinley, have you been to test the changes?

Not yet, but likely today.

Cheers,

Rich

Sent from my phone.

On Feb 15, 2011, at 10:09 AM, Timo Westkämper <email address hidden> wrote:

> McKinley, have you been to test the changes?
>
> --
> You received this bug notification because you are a direct subscriber
> of the bug.
> https://bugs.launchpad.net/bugs/704638
>
> Title:
> Codegen with no Prefix Overwrites Bean Files
>
> Status in Querydsl:
> Fix Committed
>
> Bug description:
> If codegen is run with empty string as a prefix then the bean and the
> "Q" class will have the same file name. Please consider separate
> table-model-prefix, table-model-suffix, bean-prefix, bean-suffix and
> independent bean-package settings to help the generated code fit a
> wide range of naming and package styles.
>
> Alternately, it might be easier for just two settings that are
> templates for table model and bean, "org.my.db.sales.Q{0}" and
> "org.my.db.sales.beans.{0}Bean". Those patterns could be parsed to get
> the package names and the class name from the NamingStrategy could be
> applied in place of "{0}" or similar placeholder.
>
> MetaDataExporter.java
>
> private void handleTable(DatabaseMetaData md, ResultSet tables) throws SQLException {
> String tableName = tables.getString(TABLE_NAME);
> String className = namingStrategy.getClassName(namePrefix, tableName);
> if (beanSerializer != null){
> className = className.substring(namePrefix.length());
> }
> EntityType classModel = createEntityType(tableName, className);
> ...
> }
>
> To unsubscribe from this bug, go to:
> https://bugs.launchpad.net/querydsl/+bug/704638/+subscribe

Released in 2.1.2

Changed in querydsl:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers