views:

301

answers:

2

Hi,

I am using grails 1.1.1 and i got this error collection [Person.companies] was not processed by flush()

the configuration is as follow: Person domain has many companies (Company domain) while Company belongsTo Person

then in the controller I did like this

def person = session.person ; 
def jobs =  Job.findByPerson(person);
jobs.currentSalary = new BigDecimal(params.currentSalary);
... another code ... 

jobs.save(flush:true);

it produce the following error: collection [Person.companies] was not processed by flush()

I tried to change the first line from

def person = session.person;
to
def person = Person.get(session.person.id);

I read on the mailing list, someone said it related to searchable plugin but I am not using that one.

and it works ...

my question, why i cannot use session.person that contains the same object.

thanks you

A: 

I ran into a similar problem when person.company was defined as a List rather than a Set or SortedSet. In my case, I ended up having to change the compareTo function of Company so that SortedSet worked properly. It seemed to be an odd interaction between these JIRAs 2986 and 4453 that I didn't have time to sort out. The root problem involves some lazy loading of collections.

http://jira.codehaus.org/browse/GRAILS-4453 (can only post one hyperlink)

+1  A: 

try this: replace def person = session.person; by

def person = session.person.attach();