/** * Begin read-only transaction. Default to regular transaction. * * @return the database transaction */ default DataStoreTransaction beginReadTransaction() { return beginTransaction(); } }
@Override protected DataStoreTransaction beginTransaction(DataStore dataStore) { // begin read transaction return dataStore.beginReadTransaction(); }
@Override public void populateEntityDictionary(EntityDictionary dictionary) { this.dictionary = dictionary; for (DataStore dataStore : dataStores) { EntityDictionary subordinateDictionary = new EntityDictionary(dictionary.getCheckMappings()); dataStore.populateEntityDictionary(subordinateDictionary); for (Class<?> cls : subordinateDictionary.getBindings()) { // route class to this database manager this.dataStoreMap.put(cls, dataStore); // bind to multiplex dictionary dictionary.bindEntity(cls); dictionary.bindInitializer(subordinateDictionary::initializeEntity, cls); } } }
/** * Instantiates a new Elide instance. * * @param elideSettings Elide settings object */ public Elide(ElideSettings elideSettings) { this.elideSettings = elideSettings; this.auditLogger = elideSettings.getAuditLogger(); this.dataStore = elideSettings.getDataStore(); this.dataStore.populateEntityDictionary(elideSettings.getDictionary()); this.mapper = elideSettings.getMapper(); elideSettings.getSerdes().forEach((targetType, serde) -> { CoerceUtil.register(targetType, serde); }); }
@Override protected DataStoreTransaction beginTransaction(DataStore dataStore) { // begin updating transaction return dataStore.beginTransaction(); }
/** * Instantiates a new Elide instance. * * @param elideSettings Elide settings object */ public Elide(ElideSettings elideSettings) { this.elideSettings = elideSettings; this.auditLogger = elideSettings.getAuditLogger(); this.dataStore = elideSettings.getDataStore(); this.dataStore.populateEntityDictionary(elideSettings.getDictionary()); this.mapper = elideSettings.getMapper(); elideSettings.getSerdes().forEach((targetType, serde) -> { CoerceUtil.register(targetType, serde); }); }
@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); }
/** * Begin read-only transaction. Default to regular transaction. * * @return the database transaction */ default DataStoreTransaction beginReadTransaction() { return beginTransaction(); } }
@Test public void verifySession() throws IOException { try (DataStoreTransaction tx = dataStore.beginTransaction()) { tx.commit(null); } }
/** * Attempt to reverse changes of last commit since not all transactions successfully committed. * @param restoreList List of database managers to reverse the last commit * @param cause cause to add any suppressed exceptions */ private void reverseTransactions(ArrayList<DataStore> restoreList, Throwable cause, RequestScope requestScope) { for (DataStore dataStore : restoreList) { try (DataStoreTransaction transaction = dataStore.beginTransaction()) { List<Object> list = dirtyObjects.get(dataStore); for (Object dirtyObject : list == null ? Collections.emptyList() : list) { Object cloned = clonedObjects.get(dirtyObject); if (cloned == NEWLY_CREATED_OBJECT) { transaction.delete(dirtyObject, requestScope); } else { transaction.save(cloned, requestScope); } } transaction.commit(requestScope); } catch (RuntimeException | IOException e) { cause.addSuppressed(e); } } }
JsonNode jsonDocument) { boolean isVerbose = false; try (DataStoreTransaction tx = elide.getDataStore().beginTransaction()) { final User user = tx.accessUser(getUser.apply(securityContext)); GraphQLRequestScope requestScope = new GraphQLRequestScope(tx, user, elide.getElideSettings());
@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(); } }
JsonNode jsonDocument) { boolean isVerbose = false; try (DataStoreTransaction tx = elide.getDataStore().beginTransaction()) { final User user = tx.accessUser(getUser.apply(securityContext)); GraphQLRequestScope requestScope = new GraphQLRequestScope(tx, user, elide.getElideSettings());
@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(); }
@BeforeClass public static void setup() throws IOException { DataStoreTransaction tx = dataStore.beginTransaction();