This week's book giveaways are in the Jython/Python and Object-Oriented programming forums.
We're giving away four copies each of Machine Learning for Business: Using Amazon SageMaker and Jupyter and Object Design Style Guide and have the authors on-line!
See this thread and this one for details.
Win a copy of Machine Learning for Business: Using Amazon SageMaker and JupyterE this week in the Jython/Python forum
or Object Design Style Guide in the Object-Oriented programming forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

Hibernate batch update via a table, throws cannot modify a column which maps to a non key-preserved

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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.
<class
name="com.common.to.AccountTO" entity-name="AccountTOView"
table="ACCOUNT"
lazy="true"
>
-------------------------
<class
name="com.common.to.AccountTO" entity-name="AccountTO"
table="CST_HDR"
lazy="true"
>

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 ?

Thanks

 
Did you miss me? Did you miss this tiny ad?
Sauce Labs - World's Largest Continuous Testing Cloud for Websites and Mobile Apps
https://coderanch.com/t/722574/Sauce-Labs-World-Largest-Continuous
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!