Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hibernate tool, auto cascade all

I have a database and I generated all bean and hbm.xml files with hibernate tool.

I noticed this tool not generated automatically the cascade property... I read it can be done using reveng.xml.

There are ways to auto-generate revenge.xml, or set a cascade property 1 time for all tables?

like image 234
Andrea Catania Avatar asked Jun 04 '14 10:06

Andrea Catania


1 Answers

There are multiple options for the auto property:

  • create - It creates new tables corresponding mapping or annotation. It drops existing tables and data.
  • update - It keeps existing data and tables. It updates the schema. here we have to take care contracts.
  • create-drop - It is same like create but once session gets closed it drops everything.
  • validate - it validates or matches schema with map or annotation. It's valid for a Production environment.

Propery hbm2ddl.auto = update in configuration xml.

If you want to delete cascade you should add to your collection in XML the following:

cascade="delete-orphan" 
cascade="save-update, delete"
like image 134
Levik Avatar answered Sep 28 '22 13:09

Levik