-3

Why we are using cascading in Java?? What is its importance. Here i am using for save and update

Stock stock = new Stock();
StockDailyRecord stockDailyRecords = new StockDailyRecord();
//set the stock and stockDailyRecords  data

stockDailyRecords.setStock(stock);        
stock.getStockDailyRecords().add(stockDailyRecords);

session.save(stock);
session.save(stockDailyRecords);

Is there any alternate way for cascading.?

Ashish
  • 1
  • 3
  • As the site where your example can be found tells, _cascade_ keyword can be used to avoid having to persist each sub-element "manually" : see : http://www.mkyong.com/hibernate/hibernate-cascade-example-save-update-delete-and-delete-orphan/ – Arnaud Jan 19 '16 at 09:06
  • Hi Berger for more understanding i am asking this question . – Ashish Jan 21 '16 at 09:11

1 Answers1

1

Cascade attribute transfers operations done on one object onto its related child objects. if we write cascade = β€œall” then all operations like insert, delete, update at parent object will be effected to child object also

bNd
  • 7,512
  • 7
  • 39
  • 72