I have 2 tables in grails with mysql
say A and B
The scenarios that I want to implement here are :
(1)instance of A can have zero / one / more than one instance of B.
(2)when instance A is deleted then all its related Bs must be deleted.
(3)each instance of B must be associated with only one instance of A.
(4)A knows about B , but B does not know about A.
condition number 4 is not mandatory.
From the above info it seems like : unidirectional one to many from A to B
Currently what I am doing is: (taking help from here )
class A
{
String name
Set bs=[]
static hasMany=[bs:B]
}
Class B
{
String name
}
B b=new B(name:'bname')
b.save()
A a=new A(name:'aname')
a.addToBs(b)
a.save()
While saving both entries,(B is saving but A is not saving) I am using addTo and getting error no signature of the method addToBs()
Please help me and also correct me if I am wrong somewhere.