Last active
August 29, 2015 14:02
-
-
Save gunnarmorling/d999fb3bee4c01a8e186 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
@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