Saveorupdate is not updating
(Applications that use this kind of approach in a high-concurrency environment usually use versioned data to ensure transaction isolation.) This approach requires a slightly different programming model to the one described in the last section.NHibernate supports this model by providing the method (cat Id); Cat potential Mate = new Cat(); first Session.
Cascade is a very convenient feature to manage the state of the other side automatically.In this example, if a ‘Stock’ is saved, all its referenced ‘stock Daily Records’ should be saved into database as well. Stock Daily Record sdr1 = (Stock Daily Record)session.get(Stock Daily Record.class, new Integer(56)); Stock Daily Record sdr2 = (Stock Daily Record)session.get(Stock Daily Record.class, new Integer(57)); Stock stock = (Stock)session.get(Stock.class, new Integer(2)); Stock Daily Records().remove(sdr1); Stock Daily Records().remove(sdr2); Or Update(stock); Further study – Cascade – JPA & Hibernate annotation common mistake.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); session.save(stock Daily Records); 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 (? Both are totally different notions, see the differential here.Performance issue In a large table with many columns (legacy design) or contains large data volumes, update some unmodified columns are absolutely unnecessary and great impact on the system performance.based upon your requirement for persisting object into Database.