gorm - Grails can't get to cascade save many-to-one from form -


i have many-to-one relationship want expose through single form, can't cascade-save work, don't see error/exceptions in log. here's domain classes:

class person {   string name   list reminders = new arraylist()   static hasmany = [ reminders : pevent ]   static mapping = { reminders cascade:"all-delete-orphan" }   def getreminderslist() {     return lazylist.decorate(eventos, factoryutils.instantiatefactory(pevent .class))   } } class pevent implements comparable {   static belongsto = [person:person ]   static transients = [ '_deleted' ]   string eventtype   date eventdate   string comments   boolean _deleted   int compareto(object other) {     eventtype <=> other.eventtype ?: eventdate <=> other.eventdate ?: comments <=> other.comments   } } 

here's how reference reminders in form:

<div class="fieldcontain ${haserrors(bean: personinstance, field: 'reminders', 'error')} required">   <label for="reminders">     <g:message code="person.reminders.label" default="reminders" />     <span class="required-indicator">*</span>   </label>   <div id="childlist">     <g:each var="reminder" in="${personinstance.reminders}" status="i">     <div id="reminder${i}">        <g:select name="reminderslist[${i}].eventtype" from="${reminder?.constraints?.eventtype?.inlist}" required="" value="${reminder?.eventtype}" />       <g:datepicker name="reminderslist[${i}].eventdate" precision="day"  value="${reminder?.eventdate}"  />       <g:textfield name="reminderslist[${i}].comments" required="" value="${reminder?.comments}"/>       <input type="hidden" name='reminderslist[${i}]._deleted' id='reminderslist[${i}]._deleted' value='false'/>     </div>     </g:each>   </div> </div> 

and part of trace showing what's being persisted. @ beggining i'm logging what's being captured form, ok far, when person gets saved remindes collection seems empty.

2015-07-13 12:22:13,469 [http-bio-8080-exec-10] debug rescate.personservice  - par: reminderslist[0].comments=jon5com 2015-07-13 12:22:13,470 [http-bio-8080-exec-10] debug rescate.personservice  - par: reminderslist[0]=[eventtype:nacimiento, eventdate:date.struct, eventdate_day:13, eventdate_month:7, eventdate_year:2015, comments:jon5com, _deleted:false] 2015-07-13 12:22:13,470 [http-bio-8080-exec-10] debug rescate.personservice  - par: daten_month=7 2015-07-13 12:22:13,470 [http-bio-8080-exec-10] debug rescate.personservice  - par: datein_year=2015 2015-07-13 12:22:13,470 [http-bio-8080-exec-10] debug rescate.personservice  - par: reminderslist[0].eventtype=nacimiento 2015-07-13 12:22:13,470 [http-bio-8080-exec-10] debug rescate.personservice  - par: reminderslist[0]._deleted=false 2015-07-13 12:22:13,470 [http-bio-8080-exec-10] debug rescate.personservice  - par: daten_year=2015 2015-07-13 12:22:13,470 [http-bio-8080-exec-10] debug rescate.personservice  - par: dist=crt 2015-07-13 12:22:13,470 [http-bio-8080-exec-10] debug rescate.personservice  - par: reminderslist[0].eventdate_day=13 2015-07-13 12:22:13,472 [http-bio-8080-exec-10] debug rescate.personservice  - par: create=create 2015-07-13 12:22:13,472 [http-bio-8080-exec-10] debug rescate.personservice  - par: reminderslist[0].eventdate_year=2015 2015-07-13 12:22:13,472 [http-bio-8080-exec-10] debug rescate.personservice  - par: datein_day=13 2015-07-13 12:22:13,472 [http-bio-8080-exec-10] debug rescate.personservice  - par: name=jon5 2015-07-13 12:22:13,472 [http-bio-8080-exec-10] debug rescate.personservice  - par: loop=cm 2015-07-13 12:22:13,472 [http-bio-8080-exec-10] debug rescate.personservice  - par: datein=date.struct 2015-07-13 12:22:13,473 [http-bio-8080-exec-10] debug rescate.personservice  - par: gnd=m 2015-07-13 12:22:13,473 [http-bio-8080-exec-10] debug rescate.personservice  - par: tim=1m 2015-07-13 12:22:13,473 [http-bio-8080-exec-10] debug rescate.personservice  - par: dateofintake_month=7 2015-07-13 12:22:13,473 [http-bio-8080-exec-10] debug rescate.personservice  - par: reminderslist[0].eventdate_month=7 2015-07-13 12:22:13,474 [http-bio-8080-exec-10] debug rescate.personservice  - par: dateneutered_day=13 2015-07-13 12:22:13,475 [http-bio-8080-exec-10] debug rescate.personservice  - par: reminderslist[0].eventdate=date.struct 2015-07-13 12:22:13,475 [http-bio-8080-exec-10] debug rescate.personservice  - par: dateneutered=date.struct 2015-07-13 12:22:13,475 [http-bio-8080-exec-10] debug rescate.personservice  - par: spc=notes2 2015-07-13 12:22:13,475 [http-bio-8080-exec-10] debug rescate.personservice  - par: action=save 2015-07-13 12:22:13,475 [http-bio-8080-exec-10] debug rescate.personservice  - par: format=null 2015-07-13 12:22:13,475 [http-bio-8080-exec-10] debug rescate.personservice  - par: controller=person 2015-07-13 12:22:13,615 [http-bio-8080-exec-10] trace internal.sessionimpl  - setting flush mode to: manual 2015-07-13 12:22:13,616 [http-bio-8080-exec-10] trace internal.sessionimpl  - setting flush mode to: auto 2015-07-13 12:22:13,616 [http-bio-8080-exec-10] debug hibernate.grailshibernatetemplate  - found thread-bound session hibernatetemplate 2015-07-13 12:22:13,617 [http-bio-8080-exec-10] trace internal.sessionimpl  - setting flush mode to: manual 2015-07-13 12:22:13,617 [http-bio-8080-exec-10] trace internal.abstractsaveeventlistener  - transient instance of: org.ppl.person 2015-07-13 12:22:13,617 [http-bio-8080-exec-10] trace internal.defaultsaveorupdateeventlistener  - saving transient instance 2015-07-13 12:22:13,618 [http-bio-8080-exec-10] trace internal.abstractsaveeventlistener  - saving [org.ppl.person#<null>] 2015-07-13 12:22:13,618 [http-bio-8080-exec-10] trace internal.cascade  - processing cascade action_save_update for: org.ppl.person 2015-07-13 12:22:13,618 [http-bio-8080-exec-10] trace internal.cascade  - done processing cascade action_save_update for: org.ppl.person 2015-07-13 12:22:13,618 [http-bio-8080-exec-10] trace internal.versioning  - seeding: 0 2015-07-13 12:22:13,618 [http-bio-8080-exec-10] trace spi.actionqueue  - adding entityidentityinsertaction [org.ppl.person] object 2015-07-13 12:22:13,618 [http-bio-8080-exec-10] trace spi.actionqueue  - executing inserts before finding non-nullable transient entities insert: [entityidentityinsertaction[org.ppl.person#<null>]] 2015-07-13 12:22:13,619 [http-bio-8080-exec-10] trace spi.actionqueue  - adding insert no non-nullable, transient entities: [entityidentityinsertaction[org.ppl.person#<null>]] 2015-07-13 12:22:13,619 [http-bio-8080-exec-10] trace spi.actionqueue  - executing insertions before resolved early-insert 2015-07-13 12:22:13,619 [http-bio-8080-exec-10] debug spi.actionqueue  - executing identity-insert 2015-07-13 12:22:13,619 [http-bio-8080-exec-10] trace internal.sessionimpl  - setting flush mode to: manual 2015-07-13 12:22:13,621 [http-bio-8080-exec-10] trace entity.abstractentitypersister  - inserting entity: org.ppl.person (native id) 2015-07-13 12:22:13,621 [http-bio-8080-exec-10] trace entity.abstractentitypersister  - version: 0 2015-07-13 12:22:13,622 [http-bio-8080-exec-10] debug hibernate.sql  - insert animal (id, version, gnd, daten, datein, tim, spc, name, dist, loop) values (null, ?, ?, ?, ?, ?, ?, ?, ?, ?) 2015-07-13 12:22:13,623 [http-bio-8080-exec-10] trace internal.jdbccoordinatorimpl  - registering statement [prep38: insert animal (id, version, gnd, daten, datein, edad, spc, name, dist, loop) values (null, ?, ?, ?, ?, ?, ?, ?, ?, ?)] 2015-07-13 12:22:13,623 [http-bio-8080-exec-10] trace entity.abstractentitypersister  - dehydrating entity: [org.ppl.person#<null>] 2015-07-13 12:22:13,624 [http-bio-8080-exec-10] trace sql.basicbinder  - binding parameter [1] [bigint] - [0] 2015-07-13 12:22:13,624 [http-bio-8080-exec-10] trace sql.basicbinder  - binding parameter [2] [varchar] - [male] 2015-07-13 12:22:13,624 [http-bio-8080-exec-10] trace sql.basicbinder  - binding parameter [3] [timestamp] - [mon jul 13 00:00:00 art 2015] 2015-07-13 12:22:13,624 [http-bio-8080-exec-10] trace sql.basicbinder  - binding parameter [4] [timestamp] - [mon jul 13 00:00:00 art 2015] 2015-07-13 12:22:13,626 [http-bio-8080-exec-10] trace sql.basicbinder  - binding parameter [5] [varchar] - [1m] 2015-07-13 12:22:13,626 [http-bio-8080-exec-10] trace sql.basicbinder  - binding parameter [6] [varchar] - [notes2] 2015-07-13 12:22:13,626 [http-bio-8080-exec-10] trace sql.basicbinder  - binding parameter [7] [varchar] - [jon5] 2015-07-13 12:22:13,627 [http-bio-8080-exec-10] trace sql.basicbinder  - binding parameter [8] [varchar] - [crt] 2015-07-13 12:22:13,627 [http-bio-8080-exec-10] trace sql.basicbinder  - binding parameter [9] [varchar] - [cm] 2015-07-13 12:22:13,628 [http-bio-8080-exec-10] debug id.identifiergeneratorhelper  - natively generated identity: 2 2015-07-13 12:22:13,628 [http-bio-8080-exec-10] trace internal.jdbccoordinatorimpl  - releasing result set [rs42: org.h2.result.localresult@2a3ba9ee columns: 1 rows: 1 pos: 0] 2015-07-13 12:22:13,628 [http-bio-8080-exec-10] trace internal.jdbccoordinatorimpl  - closing result set [rs42: org.h2.result.localresult@2a3ba9ee columns: 1 rows: 1 pos: 0] 2015-07-13 12:22:13,631 [http-bio-8080-exec-10] trace internal.jdbccoordinatorimpl  - releasing statement [prep38: insert animal (id, version, gnd, daten, datein, tim, spc, name, dist, loop) values (null, ?, ?, ?, ?, ?, ?, ?, ?, ?) {1: 0, 2: 'male', 3: timestamp '2015-07-13 00:00:00.0', 4: timestamp '2015-07-13 00:00:00.0', 5: '1m', 6: 'notes2', 7: 'jon5', 8: 'crt', 9: 'cm'}] 2015-07-13 12:22:13,631 [http-bio-8080-exec-10] trace internal.jdbccoordinatorimpl  - closing prepared statement [prep38: insert animal (id, version, gnd, daten, datein, tim, spc, name, dist, loop) values (null, ?, ?, ?, ?, ?, ?, ?, ?, ?) {1: 0, 2: 'male', 3: timestamp '2015-07-13 00:00:00.0', 4: timestamp '2015-07-13 00:00:00.0', 5: '1m', 6: 'notes2', 7: 'jon5', 8: 'crt', 9: 'cm'}] 2015-07-13 12:22:13,631 [http-bio-8080-exec-10] trace internal.jdbccoordinatorimpl  - starting after statement execution processing [on_close] 2015-07-13 12:22:13,632 [http-bio-8080-exec-10] trace internal.unresolvedentityinsertactions  - no unresolved entity inserts depended on [[org.ppl.person#2]] 2015-07-13 12:22:13,633 [http-bio-8080-exec-10] trace internal.cascade  - processing cascade action_save_update for: org.ppl.person 2015-07-13 12:22:13,633 [http-bio-8080-exec-10] trace internal.cascade  - cascade action_save_update collection: org.ppl.person.reminders 2015-07-13 12:22:13,633 [http-bio-8080-exec-10] trace internal.cascade  - done cascade action_save_update collection: org.ppl.person.reminders 2015-07-13 12:22:13,633 [http-bio-8080-exec-10] trace internal.cascade  - done processing cascade action_save_update for: org.ppl.person 2015-07-13 12:22:13,633 [http-bio-8080-exec-10] trace internal.abstractsaveeventlistener  - persistent instance of: org.ppl.person 2015-07-13 12:22:13,633 [http-bio-8080-exec-10] trace internal.defaultsaveorupdateeventlistener  - ignoring persistent instance 2015-07-13 12:22:13,634 [http-bio-8080-exec-10] trace internal.defaultsaveorupdateeventlistener  - object associated session: [org.ppl.person#2] 2015-07-13 12:22:13,634 [http-bio-8080-exec-10] trace internal.unresolvedentityinsertactions  - no entity insert actions have non-nullable, transient entity dependencies. 2015-07-13 12:22:13,635 [http-bio-8080-exec-10] trace internal.abstractflushingeventlistener  - flushing session 2015-07-13 12:22:13,635 [http-bio-8080-exec-10] debug internal.abstractflushingeventlistener  - processing flush-time cascades 2015-07-13 12:22:13,635 [http-bio-8080-exec-10] trace internal.cascade  - processing cascade action_save_update for: org.ppl.person 2015-07-13 12:22:13,635 [http-bio-8080-exec-10] trace internal.cascade  - cascade action_save_update collection: org.ppl.person.reminders 2015-07-13 12:22:13,635 [http-bio-8080-exec-10] trace internal.cascade  - done cascade action_save_update collection: org.ppl.person.reminders 2015-07-13 12:22:13,635 [http-bio-8080-exec-10] trace internal.cascade  - done processing cascade action_save_update for: org.ppl.person 2015-07-13 12:22:13,635 [http-bio-8080-exec-10] debug internal.abstractflushingeventlistener  - dirty checking collections 2015-07-13 12:22:13,635 [http-bio-8080-exec-10] trace internal.abstractflushingeventlistener  - flushing entities , processing referenced collections 2015-07-13 12:22:13,636 [http-bio-8080-exec-10] trace internal.wrapvisitor  - wrapped collection in role: org.ppl.person.reminders 2015-07-13 12:22:13,636 [http-bio-8080-exec-10] debug internal.collections  - collection found: [org.ppl.person.reminders#2], was: [<unreferenced>] (initialized) 2015-07-13 12:22:13,636 [http-bio-8080-exec-10] trace internal.abstractflushingeventlistener  - processing unreferenced collections 2015-07-13 12:22:13,636 [http-bio-8080-exec-10] trace internal.abstractflushingeventlistener  - scheduling collection removes/(re)creates/updates 2015-07-13 12:22:13,637 [http-bio-8080-exec-10] debug internal.abstractflushingeventlistener  - flushed: 0 insertions, 0 updates, 0 deletions 1 objects 2015-07-13 12:22:13,637 [http-bio-8080-exec-10] debug internal.abstractflushingeventlistener  - flushed: 1 (re)creations, 0 updates, 0 removals 1 collections 2015-07-13 12:22:13,637 [http-bio-8080-exec-10] debug util.entityprinter  - listing entities: 2015-07-13 12:22:13,637 [http-bio-8080-exec-10] debug util.entityprinter  - org.ppl.person{loop=cm, name=jon5, id=2, imagenes=null, datein=mon jul 13 00:00:00 art 2015, gnd=male, tim=1m, dist=crt, reminders=[], daten=mon jul 13 00:00:00 art 2015, spc=notes2, version=0} 2015-07-13 12:22:13,638 [http-bio-8080-exec-10] trace internal.abstractflushingeventlistener  - executing flush 2015-07-13 12:22:13,638 [http-bio-8080-exec-10] debug collection.abstractcollectionpersister  - inserting collection: [org.ppl.person.reminders#2] 2015-07-13 12:22:13,639 [http-bio-8080-exec-10] debug collection.abstractcollectionpersister  - collection empty 

any clues welcomed.

i found issue. following example (http://www.2paths.com/2009/10/01/one-to-many-relationships-in-grails-forms/) lazylist accessed through getter, , form fields reference 'expandable' list.. well, issue, form fields need have name of domain's collection list grails can perform data-binding. approach: in order add new fields form use ajax call action in controller, new child , render template it, in form append template list of childs. creation, rely on grails data-binding. i'm still not sure why or how in example 2paths above done through expandable list.

class author {   static constraints = {    }   string name   list books = new arraylist()   static hasmany = [ books:book ]   static mapping = {       books cascade:"all-delete-orphan"   }   def getexpandablebooklist() {       return lazylist.decorate(books,factoryutils.instantiatefactory(book.class))   } } 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -