लेनदेन.com() क्या करता है?हाइबरनेट में banking.commit() क्या है?
Account account = new Account();
account.setId(100);
account = (Account) session.get(Account.class, account.getId());
System.out.println("Before Transaction: Balance = " + account.getBalance());
double preBal = account.getBalance();
account.setBalance(50000000);
Transaction transaction = session.beginTransaction();
session.update(account);
account = (Account) session.get(Account.class, account.getId());
System.out.println("After Transaction: Balance = " + account.getBalance());
// transaction.commit();
account = (Account) session.get(Account.class, account.getId());
System.out.println("Pev-Bal=" + preBal + " Curr-Bal=" + account.getBalance());
यह मैं परिणाम देता है:
Hibernate: select account0_.id as id0_1_, account0_.balance as ..........
Before Transaction: Balance = 300.0
After Transaction: Balance = 5.0E7
Pev-Bal=300.0 Curr-Bal=5.0E7
लेकिन चूंकि मैं transaction.commit फोन नहीं किया() वहाँ डाटाबेस में कोई बदलाव नहीं किया गया था।
क्या इसका मतलब यह है कि सब कुछ केवल कुछ उदाहरण/ऑब्जेक्ट्स पर ही डेटाबेस को बदल दिए बिना किया गया था?
मैं हाइबरनेट के लिए नया हूं, इसलिए कृपया मुझे समझने में सहायता करें। मैं हाइबरनेट उपयोग कर रहा हूँ 4.
अद्यतन:
अगर मैं transaction.commit फोन() तो परिणाम इस लाइन
Hibernate: update account set balance=? where id=?
और डाटाबेस को भी अद्यतन किया है।
क्या इसका मतलब यह है कि लेनदेन.com() पर कॉल किए बिना सबकुछ केवल डेटाबेस स्तर को बदले बिना उदाहरण स्तर पर किया गया था?