Win a copy of Rust Web Development this week in the Other Languages 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Hibernate: How to prevent insert and delete?

 
Ranch Hand
Posts: 532
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1- How can I prevent insert and delete functions on a specific table/class?

2- How can I instruct hibernate not to persist the changes in an entity without call 'Update' explicitly?

I ran into a situation where a property of an entity is changed, but no the update function was not called. When the transaction is committed, hibernate persisted the changes to the database. Can this feature be disabled?
 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try using proper combination of
session.evict() and session.clear() before session.update() or session.save()
 
Hanna Habashy
Ranch Hand
Posts: 532
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Try using proper combination of
session.evict() and session.clear() before session.update() or session.save()



Did you mean to call session.clear() or session.evict() before I commit my transaction?

Because my point was the data is persisted even if I don't call update.
 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Please check this property hibernate.connection.autocommit property in hibernate.cfg.xml file

and also please have a look on the following link, search string is "automatic dirty checking"

http://www.hibernate.org/hib_docs/v3/reference/en/html/tutorial.html

Regards,
Sankar. S
 
sangram mhatre
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please check setreadOnly() method.
http://www.hibernate.org/hib_docs/v3/api/org/hibernate/Session.html#setReadOnly(java.lang.Object,%20boolean)

Else you can write you own wrapper class to control the dirty checking .
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic