) Stock stock = new Stock(); Stock Daily Record stock Daily Records = new Stock Daily Record(); //set the stock and stock Daily Records data stock Daily Stock(stock); Stock Daily Records().add(stock Daily Records); session.save(stock); Hibernate: insert into mkyong.stock (STOCK_CODE, STOCK_NAME) values (? ) Hibernate: insert into mkyong.stock_daily_record (STOCK_ID, PRICE_OPEN, PRICE_CLOSE, PRICE_CHANGE, VOLUME, DATE) values (? How about if you just want to delete two referenced ‘stock Daily Records’ records?
Save Or Update(cat); // update existing state (cat has a non-null id) second Session.
Save Or Update(mate); // save the new instance (mate has a null id).
(Except for lifecycle objects, discussed later.) Hibernate users have requested a general purpose method that either saves a transient instance by generating a new identifier or update the persistent state associated with its current identifier. NHibernate distinguishes “new” (unsaved) instances from “existing” (saved or loaded in a previous session) instances by the value of their identifier (or version, or timestamp) property.
The // in the first session Cat cat = (Cat) first Session.
You need to loop all the ‘stock Daily Records’ and delete it one by one.