Question

I'm upgrading an app from Grails 1.3.6 to 2.1.1. Have hit what seems to be a very strange issue.

I have a table called SECTION. This call:

def testSection = Section.get(94725)

Generates this SQL in Grails 1.3.6:

select
    section0_.ID as ID42_0_,
    section0_.concept_tag_uri as concept2_42_0_,
    section0_.INDEX_ID as INDEX3_42_0_,
    section0_.LIVE_IND as LIVE4_42_0_,
    section0_.NAME as NAME42_0_,
    section0_.PARENT_ID as PARENT6_42_0_,
    section0_.ASST_INDEX_ASSET_ID as ASST7_42_0_,
    section0_.ORDER_NO as ORDER8_42_0_,
    section0_.SITE_ID as SITE9_42_0_,
    section0_.TYPE_ID as TYPE10_42_0_,

    (SELECT
        uk_sec.id 
    FROM
        section uk_sec,
        site uk_site 
    WHERE
        uk_sec.index_id = section0_.index_id 
        AND uk_sec.site_id = uk_site.siteid 
        AND uk_site.audienceid  = 1) as formula1_0_ 
from
    SECTION section0_ 
where
    section0_.ID=?

But this SQL in 2.1.1:

select 
    section0_.ID as ID45_0_, 
    section0_.concept_tag_uri as concept2_45_0_, 
    section0_.INDEX_ID as INDEX3_45_0_, 
    section0_.LIVE_IND as LIVE4_45_0_, 
    section0_.NAME as NAME45_0_, 
    section0_.PARENT_ID as PARENT6_45_0_, 
    section0_.ASST_INDEX_ASSET_ID as ASST7_45_0_, 
    section0_.ORDER_NO as ORDER8_45_0_, 
    section0_.SITE_ID as SITE9_45_0_, 

    (SELECT 
        uk_sec.id 
    FROM section uk_sec, 
        site uk_site 
    WHERE uk_sec.index_id = section0_.index_id 
        AND uk_sec.site_id = uk_site.siteid 
        AND uk_site.audienceid  = 1) as formula1_0_ 
from 
    SECTION section0_ where section0_.ID=?

Looks similar, but this part is missing in the 2.1.1 version:

section0_.TYPE_ID as TYPE10_42_0_,

This is the mapping in the class:

...
String sectionType
...
static mapping = 
{
    table 'SECTION'
    version false
    id generator:'assigned'

    columns {
                    ...
        sectionType  column: 'TYPE_ID'
                    ...
    }
}

The DB field in question is: TYPE_ID CHAR(1) but as the SQL is generated as a result of the get(), am assuming it's nothing to do with the actual DB schema or column(?).

The fact that it's the final element in the list of select fields makes me think it's somehow related, but I don't know how to change that, or if doing so would just 'delete' another field from the statement.

Anyone seen anything like this?

Cheers, spacebot

Était-ce utile?

La solution

Maybe somewhat hasty to think it might be a bug.

The parameter type of the overridden setter is required for Grails2.1.1, it's more forgiving in 1.x.

public void setType(type) { ... }  // works in 1.3.6, breaks 2.1.1

public void setType(String type) { ... }  // ok in 2.1.1
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top