Created
June 26, 2016 22:46
-
-
Save przodownikR1/9f4e6ff5960a99449a7efcd4023e551b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Session session = getSession(); | |
Transaction tx = null; | |
tx = session.beginTransaction(); | |
Book book = (Book)session.get(Book.class, new Long(1)); | |
String name = (String) session.createQuery("select b.name from bkch b where b.isbn = :isbn").setParameter("isbn", book.getIsbn()).uniqueResult(); | |
System.out.println("book Name- "+name); | |
tx.commit(); | |
session.close(); | |
//Read Committed to Repeatable Read comes with scalability issues | |
Session session = getSession(); | |
Transaction tx = null; | |
tx = session.beginTransaction(); | |
Book book = (Book)session.get(Book.class, new Long(1)); | |
session.lock(book, LockMode.UPGRADE); | |
String name = (String) session.createQuery("select b.name from bkch b where b.isbn = :isbn").setParameter("isbn", book.getIsbn()).uniqueResult(); | |
System.out.println("book Name- "+name); | |
tx.commit(); | |
session.close(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment