One to one cascade save delete failure

dinesh19aug

New member
Hi,
I have a Address class and a Business class.
Every Business hasOne address. When I write the integration test for this it fails. Here is my code

class Business {

String b_name;
static hasOne=[address:Address]

static constraints = {
address(nullable: true)
}
}

class Address {

String addline
Business business

static constraints = {
}
}

*********************INTEGRATION TEST ******************
void testSaveCascadeBusinessAddress(){

def address = new Address(addLine:"My Address")
def business = new Business(b_name:"My Business", address:address)
assertNotNull business.save() /// FAILS

//assertNotNull new Business(b_name:"My Business", address:new Address(addline:"My Address")).save() ///// PASSES
}

Why does the first asser fails while the other passes??
What am I missing here?
 
Top