@Override public void close() throws IOException { IOException cause = null; for (DataStoreTransaction transaction : transactions.values()) { try { transaction.close(); } catch (IOException | Error | RuntimeException e) { if (cause != null) { cause.addSuppressed(e); } else if (e instanceof IOException) { cause = (IOException) e; } else { cause = new IOException(e); } } } transactions.clear(); if (cause != null) { throw cause; } }
@Test (dataProvider = "like_queries_hql") public void testSpecialCharacterLikeQueryHQL(FilterPredicate filterPredicate, int noOfRecords) throws Exception { DataStoreTransaction tx = dataStore.beginReadTransaction(); RequestScope scope = mock(RequestScope.class); EntityDictionary dictionary = new EntityDictionary(new HashMap<>()); dictionary.bindEntity(Book.class); when(scope.getDictionary()).thenReturn(dictionary); Pagination pagination = mock(Pagination.class); when(pagination.isGenerateTotals()).thenReturn(true); tx.loadObjects(Book.class, Optional.of(filterPredicate), Optional.empty(), Optional.of(pagination), scope); tx.commit(scope); tx.close(); verify(pagination).setPageTotals(noOfRecords); }
@Test public void accessParentBean() throws IOException { DataStoreTransaction tx = dataStore.beginTransaction(); Parent parent = new Parent(); parent.setChildren(new HashSet<>()); parent.setSpouses(new HashSet<>()); tx.createObject(parent, null); tx.commit(null); tx.close(); } }
@BeforeClass public static void setup() throws IOException { DataStoreTransaction tx = dataStore.beginTransaction(); Embedded embedded = new Embedded(); // id 1 embedded.setSegmentIds(ImmutableSet.of(3L, 4L, 5L)); tx.createObject(embedded, null); Left left = new Left(); Right right = new Right(); left.setOne2one(right); right.setOne2one(left); tx.createObject(left, null); tx.createObject(right, null); tx.commit(null); tx.close(); }
tx.close();