I have a view (used to ONLY fetch and display data) and table (used for INSERTS and UPDATES)
Following is the mapping in hibernate mapping file , both table and view are mapped to same POJO but underlying table are different.
When i do a batch update (Object update -HibernateSession.update(AccountTO, obj); ) , few records get updated OK and then hibernate throws following exception :
cannot modify a column which maps to a non key-preserved table
2011-05-14 23:09:49,320 INFO [STDOUT] 14 May 2011 23:09:49,305 [DefaultQuartzScheduler_Worker-5] ERROR org.hibernate.event.def.AbstractFlushingEventListener : Could not synchronize database state with session
org.hibernate.exception.SQLGrammarException: could not update: [AccountTOView#452283]
Am using Spring's HibernateTemplate to do the update.
Any directions to get rid off this exception will be a great help, looks like a weird behaviour, since few records are updated fine.
Is it hibernate session behaviour which is looking for AccountTOView even when update should be ideally done via AccountTO which is mapped to CST_HDR table ?
subject: Hibernate batch update via a table, throws cannot modify a column which maps to a non key-preserved