tags:

views:

92

answers:

0

I had two domains :
class CoverageList { Integer id Integer pub_cat_id Integer brand_id Integer brand_set_no String cov_list_desc Date edit_date

static hasMany = [assoc_cov_lists : AssocCovList]
static belongsTo = [brand : Brand ]
static fetchMode = [assoc_cov_lists:'eager']


static constraints = {
}

static mapping = {
    table 'coverage_list'
    version false
    id column : 'COV_LIST_ID'
    pub_cat_id column : 'PUB_CATEGORY_ID'
    brand_id column : 'BRAND_ID'
    brand_set_no column : 'BRAND_SET_NO'
    cov_list_desc column : 'COV_LIST_DESC'
    edit_date column : 'EDIT_DATE'
}

}

class Brand { Integer id String brand_name String aaia_brand_id String brand_owner_name String parent_company_name String site_link_code Date edit_date

static hasMany = [cov_lists : CoverageList]

static constraints = {
}

static mapping = {
    table 'brand'
    version false
    id column : 'BRAND_ID'
    brand_name column : 'BRAND_NAM'
}

}

My Coverage_list table looks like this :

CREATE TABLE coverage_list (
COV_LIST_ID int(11) NOT NULL,
PUB_CATEGORY_ID int(11) NOT NULL,
BRAND_ID int(11) NOT NULL,
BRAND_SET_NO int(11) NOT NULL,
COV_LIST_DESC varchar(100) NOT NULL,
EDIT_DATE date NOT NULL DEFAULT '0000-00-00',
PRIMARY KEY (COV_LIST_ID),
KEY COVERAGE_LIST_FK1 (PUB_CATEGORY_ID),
KEY COVERAGE_LIST_FK2 (BRAND_ID)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

but when using

def coverage = CoverageList.list()
coverage.each{ num ->
println num.brand.brand_name
}

I was getting error : org.hibernate.LazyInitializationException: could not initialize proxy - no Session

Please help me thanks.