Take control of your SAP testing with UiPath Test Suite
04 Data Access
1. Data Access with Hibernate Persistent objects and persistence contexts
2. Object state transitions and Session methods Transient Persistent Detached new garbage garbage delete() save() saveOrUpdate() get() load() find() iterate() etc. evict() close()* clear()* update() saveOrUpdate() lock() * affects all instances in a Session
3.
4.
5.
6.
7. The Hibernate identity scope Session session1 = sf.openSession(); Transaction tx1 = session.beginTransaction(); Object a = session1.load(Category.class, new Long(1234) ); Object b = session1.load(Category.class, new Long(1234) ); if ( a == b ) System.out.println("a and b are identicial and the same database identity."); tx1.commit(); session1.close(); Session session2 = sf.openSession(); Transaction tx2 = session.beginTransaction(); Object b2 = session2.load(Category.class, new Long(1234) ); if ( a != b2 ) System.out.println("a and b2 are not identical."); tx2.commit(); session2.close();
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22. Adding a new category to object graph Computer: Category Laptops : Category Electronics: Category Cell Phones: Category Desktop PCs: Category Monitors: Category