Grails

mapping auto-import issue

Details

  • Type: Sub-task Sub-task
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.0.1
  • Fix Version/s: 1.1-beta3
  • Component/s: Persistence
  • Labels:
    None
  • Environment:
    Windows XP
  • Testcase included:
    yes

Description

In GORM, `auto-import' seems to be false.
Moreover, the method of changing the value is necessary.

------------------- Model.groovy ---------------------------
 package com.p
 class Model {
       String name
 }
 -----------------------------------------------------------------
 import com.p.Model
 class AutoImportTests extends GroovyTestCase {
 
          void testAutoImport() {
                 def aModel = new Model(name:'Name')
                aModel.save(flush:true)
                def models = Model.findAll("from Model as m where m.name = 'Name'")           // NG
                //def models = Model.findAll("from com.p.Model as m where m.name = 'Name'")   // GOOD
               assertTrue models.size() == 1
         }
 }

Activity

Hide
Peter Ledbrook added a comment -

Having just been hit by this issue, I think it would make a good improvement. Basically, I think "auto-import" should default to "true" with the option of disabling it within a custom ORM mapping for individual domain classes.

Show
Peter Ledbrook added a comment - Having just been hit by this issue, I think it would make a good improvement. Basically, I think "auto-import" should default to "true" with the option of disabling it within a custom ORM mapping for individual domain classes.
Hide
Graeme Rocher added a comment -

Done. On by default can be disabled with:

static mapping = {
        autoImport false
    }
Show
Graeme Rocher added a comment - Done. On by default can be disabled with:
static mapping = {
        autoImport false
    }
Hide
Lari Hotari added a comment -

autoImport -feature was missing from GrailsAnnotationConfiguration ("standalone GORM"). I've added that in this commit: http://github.com/grails/grails/commit/5beb1458f8d66c94f39481ab21ca19afe316fcca

Show
Lari Hotari added a comment - autoImport -feature was missing from GrailsAnnotationConfiguration ("standalone GORM"). I've added that in this commit: http://github.com/grails/grails/commit/5beb1458f8d66c94f39481ab21ca19afe316fcca

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: