@SuppressWarnings("resource") @Override public void createObject(Object entity, RequestScope scope) { DataStoreTransaction transaction = getTransaction(entity.getClass()); transaction.createObject(entity, scope); // mark this object as newly created to be deleted on reverse transaction clonedObjects.put(entity, NEWLY_CREATED_OBJECT); }
@Override public void createObject(Object entity, RequestScope scope) { getTransaction(entity).createObject(entity, scope); }
public void saveOrCreateObjects() { dirtyResources.removeAll(newPersistentResources); // Delete has already been called on these objects dirtyResources.removeAll(deletedResources); newPersistentResources .stream() .map(PersistentResource::getObject) .forEach(s -> transaction.createObject(s, this)); dirtyResources.stream().map(PersistentResource::getObject).forEach(obj -> transaction.save(obj, this)); }
public void saveOrCreateObjects() { dirtyResources.removeAll(newPersistentResources); // Delete has already been called on these objects dirtyResources.removeAll(deletedResources); newPersistentResources .stream() .map(PersistentResource::getObject) .forEach(s -> transaction.createObject(s, this)); dirtyResources.stream().map(PersistentResource::getObject).forEach(obj -> transaction.save(obj, this)); }
@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(); }
child.setParents(Sets.newHashSet(parent)); tx.createObject(parent, null); tx.createObject(child, null); tx.createObject(p1, null); tx.createObject(c1, null); tx.createObject(c2, null); tx.createObject(p2, null); tx.createObject(p3, null); tx.createObject(c3, null); tx.createObject(c4, null); tx.createObject(bookWithPercentage, null); tx.createObject(bookWithoutPercentage, null); tx.createObject(fun, null); tx.createObject(user, null); invoice.setItems(Sets.newHashSet(item)); item.setInvoice(invoice); tx.createObject(invoice, null); tx.createObject(item, null); tx.createObject(etb, null);