org.hibernate.dialect.lock.OptimisticEntityLockException Java Examples
The following examples show how to use
org.hibernate.dialect.lock.OptimisticEntityLockException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LockModeOptimisticRaceConditionTest.java From high-performance-java-persistence with Apache License 2.0 | 6 votes |
@Test public void testExplicitOptimisticLocking() throws InterruptedException { try { doInJPA(entityManager -> { try { final Post post = entityManager.find(Post.class, 1L, LockModeType.OPTIMISTIC); PostComment comment = new PostComment(); comment.setId(1L); comment.setReview("Good one."); comment.setPost(post); lockUpgrade(entityManager, post); ready.set(true); } catch (Exception e) { throw new IllegalStateException(e); } }); } catch (OptimisticEntityLockException expected) { LOGGER.info("Failure: ", expected); } endLatch.await(); }
Example #2
Source File: LockModeOptimisticTest.java From hibernate-master-class with Apache License 2.0 | 6 votes |
@Test public void testExplicitOptimisticLocking() { try { doInTransaction(session -> { final Product product = (Product) session.get(Product.class, 1L, new LockOptions(LockMode.OPTIMISTIC)); executeSync(() -> { doInTransaction(_session -> { Product _product = (Product) _session.get(Product.class, 1L); assertNotSame(product, _product); _product.setPrice(BigDecimal.valueOf(14.49)); }); }); OrderLine orderLine = new OrderLine(product); session.persist(orderLine); }); fail("It should have thrown OptimisticEntityLockException!"); } catch (OptimisticEntityLockException expected) { LOGGER.info("Failure: ", expected); } }
Example #3
Source File: LockModeOptimisticRaceConditionTest.java From hibernate-master-class with Apache License 2.0 | 6 votes |
@Test public void testExplicitOptimisticLocking() throws InterruptedException { try { doInTransaction(session -> { try { final Product product = (Product) session.get(Product.class, 1L, new LockOptions(LockMode.OPTIMISTIC)); OrderLine orderLine = new OrderLine(product); session.persist(orderLine); lockUpgrade(session, product); ready.set(true); } catch (Exception e) { throw new IllegalStateException(e); } }); } catch (OptimisticEntityLockException expected) { LOGGER.info("Failure: ", expected); } endLatch.await(); }
Example #4
Source File: HibernateOptimisticLockingFailureException.java From spring-analysis-note with MIT License | 4 votes |
public HibernateOptimisticLockingFailureException(OptimisticEntityLockException ex) { super(ex.getMessage(), ex); }
Example #5
Source File: HibernateOptimisticLockingFailureException.java From java-technology-stack with MIT License | 4 votes |
public HibernateOptimisticLockingFailureException(OptimisticEntityLockException ex) { super(ex.getMessage(), ex); }
Example #6
Source File: HibernateOptimisticLockingFailureException.java From lams with GNU General Public License v2.0 | 4 votes |
public HibernateOptimisticLockingFailureException(OptimisticEntityLockException ex) { super(ex.getMessage(), ex); }
Example #7
Source File: HibernateOptimisticLockingFailureException.java From lams with GNU General Public License v2.0 | 4 votes |
public HibernateOptimisticLockingFailureException(OptimisticEntityLockException ex) { super(ex.getMessage(), ex); }
Example #8
Source File: HibernateOptimisticLockingFailureException.java From spring4-understanding with Apache License 2.0 | 4 votes |
public HibernateOptimisticLockingFailureException(OptimisticEntityLockException ex) { super(ex.getMessage(), ex); }
Example #9
Source File: HibernateOptimisticLockingFailureException.java From spring4-understanding with Apache License 2.0 | 4 votes |
public HibernateOptimisticLockingFailureException(OptimisticEntityLockException ex) { super(ex.getMessage(), ex); }