Hi, jdl
I tried your suggestion and also set the cascade (<set name="fields" cascade="all">), but it still doesn't work... :(
Actually, I don't know if I'm using the right mapping since I have a composition, but I didn't realize how to use the composite-element mapping, since the elements (fields) form an hiearchy (joined-subclasses).
Also, I don't know if the behavior I'm expecting is possible, that is, saving the hole tree of objects from the template (template, fields, options).
:(
The debug info is below:
23:05:14,250 DEBUG JDBCTransaction:81 - commit
23:05:14,250 DEBUG AbstractFlushingEventListener:49 - flushing session
23:05:14,250 DEBUG AbstractFlushingEventListener:99 - processing flush-time cascades
23:05:14,250 DEBUG Cascades:806 - processing cascade ACTION_SAVE_UPDATE for: br.ufrj.cos.reuse.biblioteca.template.Template
23:05:14,250 DEBUG Cascades:853 - cascade ACTION_SAVE_UPDATE for collection: br.ufrj.cos.reuse.biblioteca.template.Template.fields
23:05:14,250 DEBUG Cascades:152 - cascading to saveOrUpdate: br.ufrj.cos.reuse.biblioteca.template.field.Field
23:05:14,250 DEBUG AbstractSaveEventListener:385 - persistent instance of: br.ufrj.cos.reuse.biblioteca.template.field.Field
23:05:14,250 DEBUG DefaultSaveOrUpdateEventListener:99 - ignoring persistent instance
23:05:14,250 DEBUG DefaultSaveOrUpdateEventListener:136 - object already associated with session: [br.ufrj.cos.reuse.biblioteca.template.field.TextField#6055fa87c9053097012f66848e24f2b4]
23:05:14,250 DEBUG Cascades:871 - done cascade ACTION_SAVE_UPDATE for collection: br.ufrj.cos.reuse.biblioteca.template.Template.fields
23:05:14,250 DEBUG Cascades:831 - done processing cascade ACTION_SAVE_UPDATE for: br.ufrj.cos.reuse.biblioteca.template.Template
23:05:14,250 DEBUG Cascades:806 - processing cascade ACTION_SAVE_UPDATE for: br.ufrj.cos.reuse.biblioteca.template.field.TextField
23:05:14,250 DEBUG Cascades:853 - cascade ACTION_SAVE_UPDATE for collection: br.ufrj.cos.reuse.biblioteca.template.field.Field.options
23:05:14,250 DEBUG Cascades:871 - done cascade ACTION_SAVE_UPDATE for collection: br.ufrj.cos.reuse.biblioteca.template.field.Field.options
23:05:14,250 DEBUG Cascades:831 - done processing cascade ACTION_SAVE_UPDATE for: br.ufrj.cos.reuse.biblioteca.template.field.TextField
23:05:14,250 DEBUG AbstractFlushingEventListener:147 - dirty checking collections
23:05:14,250 DEBUG AbstractFlushingEventListener:164 - Flushing entities and processing referenced collections
23:05:14,265 DEBUG Collections:107 - Collection found: [br.ufrj.cos.reuse.biblioteca.template.Template.fields#6055fa58c905309700253498800ac2d3], was: [<unreferenced>] (initialized)
23:05:14,265 DEBUG WrapVisitor:82 - Wrapped collection in role: br.ufrj.cos.reuse.biblioteca.template.field.Field.options
23:05:14,265 DEBUG DefaultFlushEntityEventListener:119 - Updating entity: [br.ufrj.cos.reuse.biblioteca.template.field.TextField#6055fa87c9053097012f66848e24f2b4]
23:05:14,265 DEBUG Collections:107 - Collection found: [br.ufrj.cos.reuse.biblioteca.template.field.Field.options#6055fa87c9053097012f66848e24f2b4], was: [<unreferenced>] (initialized)
23:05:14,265 DEBUG AbstractFlushingEventListener:200 - Processing unreferenced collections
23:05:14,265 DEBUG AbstractFlushingEventListener:214 - Scheduling collection removes/(re)creates/updates
23:05:14,281 DEBUG AbstractFlushingEventListener:76 - Flushed: 1 insertions, 1 updates, 0 deletions to 2 objects
23:05:14,281 DEBUG AbstractFlushingEventListener:82 - Flushed: 2 (re)creations, 0 updates, 1 removals to 2 collections
23:05:14,281 DEBUG Printer:80 - listing entities:
23:05:14,281 DEBUG Printer:87 - br.ufrj.cos.reuse.biblioteca.template.Template{deleted=false, fields=[br.ufrj.cos.reuse.biblioteca.template.field.Field#6055fa87c9053097012f66848e24f2b4], name=abc, id=6055fa58c905309700253498800ac2d3}
23:05:14,281 DEBUG Printer:87 - br.ufrj.cos.reuse.biblioteca.template.field.TextField{required=true, size=12, name=textfield, id=6055fa87c9053097012f66848e24f2b4, options=[]}
23:05:14,281 DEBUG AbstractFlushingEventListener:264 - executing flush
23:05:14,281 DEBUG BasicEntityPersister:1744 - Inserting entity: [br.ufrj.cos.reuse.biblioteca.template.Template#6055fa58c905309700253498800ac2d3]
23:05:14,281 DEBUG AbstractBatcher:259 - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
23:05:14,281 DEBUG SQL:297 - insert into T_TEMPLATE (name, deleted, id) values (?, ?, ?)
23:05:14,281 DEBUG AbstractBatcher:348 - preparing statement
23:05:14,375 DEBUG BasicEntityPersister:1536 - Dehydrating entity: [br.ufrj.cos.reuse.biblioteca.template.Template#6055fa58c905309700253498800ac2d3]
23:05:14,375 DEBUG StringType:56 - binding 'abc' to parameter: 1
23:05:14,375 DEBUG BooleanType:56 - binding 'false' to parameter: 2
23:05:14,375 DEBUG StringType:56 - binding '6055fa58c905309700253498800ac2d3' to parameter: 3
23:05:14,375 DEBUG AbstractBatcher:28 - Adding to batch
23:05:14,375 DEBUG AbstractBatcher:55 - Executing batch size: 1
23:05:14,375 DEBUG AbstractBatcher:267 - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
23:05:14,375 DEBUG AbstractBatcher:368 - closing statement
23:05:14,390 DEBUG BasicEntityPersister:1859 - Updating entity: [br.ufrj.cos.reuse.biblioteca.template.field.TextField#6055fa87c9053097012f66848e24f2b4]
23:05:14,390 DEBUG AbstractBatcher:259 - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
23:05:14,390 DEBUG SQL:297 - update T_FIELD set name=?, required=? where id=?
23:05:14,390 DEBUG AbstractBatcher:348 - preparing statement
23:05:14,421 DEBUG BasicEntityPersister:1536 - Dehydrating entity: [br.ufrj.cos.reuse.biblioteca.template.field.TextField#6055fa87c9053097012f66848e24f2b4]
23:05:14,421 DEBUG StringType:56 - binding 'textfield' to parameter: 1
23:05:14,421 DEBUG BooleanType:56 - binding 'true' to parameter: 2
23:05:14,421 DEBUG StringType:56 - binding '6055fa87c9053097012f66848e24f2b4' to parameter: 3
23:05:14,421 DEBUG AbstractBatcher:28 - Adding to batch
23:05:14,421 DEBUG BasicEntityPersister:1859 - Updating entity: [br.ufrj.cos.reuse.biblioteca.template.field.TextField#6055fa87c9053097012f66848e24f2b4]
23:05:14,421 DEBUG AbstractBatcher:55 - Executing batch size: 1
23:05:14,437 ERROR AbstractBatcher:61 - Exception executing batch:
org.hibernate.StaleStateException: Batch update returned unexpected row count from update: 0 actual row count: 0 expected: 1
|