CompositePersistence implements Persistence<O, A> { public static <O, A extends Comparable<A>> CompositePersistence<O, A> of(Persistence<O, A> primaryPersistence, Persistence<O, A> secondaryPersistence, List<? extends Persistence<O, A>> additionalPersistences) { return new CompositePersistence<O, A>(primaryPersistence, secondaryPersistence, additionalPersistences); } CompositePersistence(Persistence<O, A> primaryPersistence, Persistence<O, A> secondaryPersistence, List<? extends Persistence<O, A>> additionalPersistences); @Override SimpleAttribute<O, A> getPrimaryKeyAttribute(); @Override boolean supportsIndex(Index<O> index); Persistence<O, A> getPersistenceForIndex(Index<O> index); @Override ObjectStore<O> createObjectStore(); Persistence<O, A> getPrimaryPersistence(); Persistence<O, A> getSecondaryPersistence(); List<? extends Persistence<O, A>> getAdditionalPersistences(); @Override void openRequestScopeResources(QueryOptions queryOptions); @Override void closeRequestScopeResources(QueryOptions queryOptions); static CompositePersistence<O, A> of(Persistence<O, A> primaryPersistence, Persistence<O, A> secondaryPersistence, List<? extends Persistence<O, A>> additionalPersistences); static CompositePersistence<O, A> of(Persistence<O, A> primaryPersistence, Persistence<O, A> secondaryPersistence);  }
@Test public void testCompositePersistence_EndToEnd() { OffHeapPersistence<Car, Integer> offHeapPersistence = OffHeapPersistence.onPrimaryKey(Car.CAR_ID); DiskPersistence<Car, Integer> diskPersistence = DiskPersistence.onPrimaryKey(Car.CAR_ID); IndexedCollection<Car> collection = new ConcurrentIndexedCollection<Car>(CompositePersistence.of( offHeapPersistence, diskPersistence, singletonList(OnHeapPersistence.onPrimaryKey(Car.CAR_ID)) )); collection.addIndex(DiskIndex.onAttribute(Car.MANUFACTURER)); collection.addIndex(OffHeapIndex.onAttribute(Car.MODEL)); collection.addIndex(NavigableIndex.onAttribute(Car.PRICE)); collection.addAll(CarFactory.createCollectionOfCars(1000)); ResultSet<Car> results = null; try { results = collection.retrieve( and( or( equal(Car.MANUFACTURER, "Ford"), equal(Car.MODEL, "Avensis") ), lessThan(Car.PRICE, 6000.0) ) ); Assert.assertEquals(300, results.size()); Assert.assertTrue(offHeapPersistence.getBytesUsed() > 4096); Assert.assertTrue(diskPersistence.getBytesUsed() > 4096); } finally { CloseableRequestResources.closeQuietly(results); collection.clear(); offHeapPersistence.close(); diskPersistence.getFile().delete(); } }