In controller :
AssocCovList.addAssoc(3, 4)
In Domain :
package com.org.domain
class AssocCovList {
Integer id
Integer association_id
Integer cov_list_id
Date edit_date
static belongsTo = [association : Association, cov_list : CoverageList]
static constraints = {
edit_date(nullable:true )
}
static mapping = {
table 'assoc_cov_list'
version false
columns {
id column : 'ASSOC_COV_LIST_ID'
association_id column : 'ASSOCIATION_ID'
cov_list_id column : 'COV_LIST_ID'
edit_date column : 'EDIT_DATE'
}
}
def static addAssoc(3, 4){
def aclist = new AssocCovList(association_id:3,cov_list_id:4, edit_date:new Date())
aclist.save()
}
Here is sql structure :
CREATE TABLE omni
.assoc_cov_list
(
ASSOC_COV_LIST_ID
int(11) NOT NULL auto_increment,
ASSOCIATION_ID
smallint(6) NOT NULL default '0',
COV_LIST_ID
int(11) NOT NULL default '0',
EDIT_DATE
date default NULL,
PRIMARY KEY (ASSOC_COV_LIST_ID
),
UNIQUE KEY ASSOC_COV_LIST_I2
(ASSOCIATION_ID
,COV_LIST_ID
),
KEY ASSOC_COV_LIST_FK1
(COV_LIST_ID
),
KEY ASSOC_COV_LIST_FK2
(ASSOCIATION_ID
)
) ENGINE=InnoDB AUTO_INCREMENT=9584 DEFAULT CHARSET=utf8;
This was returning No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here
why it is returning null object ? I am able to update and delete the record(s) . Not working for new record .
Please help me
thanks