Skip to content

Instantly share code, notes, and snippets.

@gunnarmorling
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gunnarmorling/d999fb3bee4c01a8e186 to your computer and use it in GitHub Desktop.
Save gunnarmorling/d999fb3bee4c01a8e186 to your computer and use it in GitHub Desktop.
@Test
public void foo() throws Exception {
getTransactionManager().begin();
EntityManager em = getFactory().createEntityManager();
// that's committed
Item item = new Item( "To thatch a roof - Ultimate Edition", 10 );
em.persist( item );
getTransactionManager().commit();
// but that's never visible (GridDialect is not invoked)
getTransactionManager().begin();
OrderLine orderLine = new OrderLine( item, 2 );
em.persist( orderLine );
item.setStock( item.getStock() - 2 );
getTransactionManager().commit();
em.clear();
getTransactionManager().begin();
item = em.find( Item.class, item.getId() );
assertThat( item.getStock() ).isEqualTo( 8 );
getTransactionManager().commit();
em.close();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment