Hibernate tool, auto cascade all
Asked Answered
N

1

19

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?

Nereen answered 4/6, 2014 at 10:14 Comment(0)
C
1

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"
Cermet answered 1/10, 2017 at 17:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.