/** * To be sure the datastoreProvider retrieves only the columns we want, * an extra column is manually added to the association document */ @Override protected void addExtraColumn() { MongoDBDatastoreProvider provider = (MongoDBDatastoreProvider) super.getService(DatastoreProvider.class); DB database = provider.getDatabase(); DBCollection collection = database.getCollection("Associations"); final BasicDBObject idObject = new BasicDBObject(2); idObject.append("Project_id", "projectID"); idObject.append("table", "Project_Module"); BasicDBObject query = new BasicDBObject(1); query.put("_id", idObject); BasicDBObject updater = new BasicDBObject(1); updater.put("$push", new BasicDBObject("extraColumn", 1)); collection.update(query, updater); }
private static RedisDatastoreProvider getProvider(SessionFactory sessionFactory) { DatastoreProvider provider = ( (SessionFactoryImplementor) sessionFactory ).getServiceRegistry().getService( DatastoreProvider.class ); if ( !( RedisDatastoreProvider.class.isInstance( provider ) ) ) { throw new RuntimeException( "Not testing with RedisDatastoreProvider, cannot extract underlying map." ); } return RedisDatastoreProvider.class.cast( provider ); }
private RedisDatastoreProvider getProvider() { SessionFactoryImplementor sessionFactory = entityManagerFactory.unwrap( SessionFactoryImplementor.class ); DatastoreProvider provider = sessionFactory.getServiceRegistry().getService( DatastoreProvider.class ); if ( !( RedisDatastoreProvider.class.isInstance( provider ) ) ) { throw new RuntimeException( "Not testing with RedisDatastoreProvider, cannot extract underlying instance." ); } return RedisDatastoreProvider.class.cast( provider ); }
@Override public void initializeSchema(SchemaDefinitionContext context) { serviceRegistry = context.getSessionFactory().getServiceRegistry(); DatastoreProvider provider = serviceRegistry.getService( DatastoreProvider.class ); if ( provider instanceof IgniteDatastoreProvider ) { IgniteDatastoreProvider igniteDatastoreProvider = (IgniteDatastoreProvider) provider; initializeEntities( context, igniteDatastoreProvider ); initializeAssociations( context, igniteDatastoreProvider ); initializeIdSources( context, igniteDatastoreProvider ); } else { throw log.unexpectedDatastoreProvider( provider.getClass(), IgniteDatastoreProvider.class ); } }
private static IgniteDatastoreProvider getProvider(SessionFactory sessionFactory) { DatastoreProvider provider = ( (SessionFactoryImplementor) sessionFactory ).getServiceRegistry().getService( DatastoreProvider.class ); if ( !( provider instanceof IgniteDatastoreProvider ) ) { throw new RuntimeException( "Not testing with Ignite, cannot extract underlying cache" ); } return (IgniteDatastoreProvider) provider; }
private static MongoDBDatastoreProvider getProvider(SessionFactory sessionFactory) { DatastoreProvider provider = ((SessionFactoryImplementor) sessionFactory).getServiceRegistry().getService( DatastoreProvider.class); if (!(MongoDBDatastoreProvider.class.isInstance(provider))) { throw new RuntimeException("Not testing with MongoDB, cannot extract underlying cache"); } return MongoDBDatastoreProvider.class.cast(provider); }
@Test public void testLoadSelectedColumns() { final String collectionName = "Drink"; MongoDBDatastoreProvider provider = (MongoDBDatastoreProvider) this.getService(DatastoreProvider.class); DB database = provider.getDatabase(); DBCollection collection = database.getCollection(collectionName); BasicDBObject water = new BasicDBObject(); water.put("_id", "1234"); water.put("name", "Water"); water.put("volume", "1L"); collection.insert(water); // List<String> selectedColumns = new ArrayList<String>(); // selectedColumns.add("name"); // Tuple tuple = this.getTuple(collectionName, "1234", selectedColumns); // // assertNotNull(tuple); // Set<String> retrievedColumn = tuple.getColumnNames(); // // /* // *The dialect will return all columns (which include _id field) so we have to substract 1 to check if // *the right number of columns has been loaded. // */ // assertEquals(selectedColumns.size(), retrievedColumn.size() - 1); // assertTrue(retrievedColumn.containsAll(selectedColumns)); collection.remove(water); }
/** * To be sure the datastoreProvider retrieves only the columns we want, * an extra column is manually added to the association document */ protected void addExtraColumn() { MongoDBDatastoreProvider provider = (MongoDBDatastoreProvider) this.getService(DatastoreProvider.class); DB database = provider.getDatabase(); DBCollection collection = database.getCollection("associations_Project_Module"); BasicDBObject query = new BasicDBObject(1); query.put("_id", new BasicDBObject("Project_id", "projectID")); BasicDBObject updater = new BasicDBObject(1); updater.put("$push", new BasicDBObject("extraColumn", 1)); collection.update(query, updater); }
@Override protected void addExtraColumn() { MongoDBDatastoreProvider provider = (MongoDBDatastoreProvider) super.getService(DatastoreProvider.class); DB database = provider.getDatabase(); DBCollection collection = database.getCollection("Project"); BasicDBObject query = new BasicDBObject(1); query.put("_id", "projectID"); BasicDBObject updater = new BasicDBObject(1); updater.put("$push", new BasicDBObject("extraColumn", 1)); collection.update(query, updater); }
@Override @Bean public DatastoreProvider datastoreProvider() { DatastoreProvider provider = (DatastoreProvider) getService(DatastoreProvider.class); if (!(EhcacheDatastoreProvider.class.isInstance(provider))) { throw new RuntimeException("Ehcache 에서 테스트를 하지 못했습니다."); } return EhcacheDatastoreProvider.class.cast(provider); }
private static EhcacheDatastoreProvider getProvider(SessionFactory sessionFactory) { DatastoreProvider provider = ((SessionFactoryImplementor) sessionFactory).getServiceRegistry() .getService(DatastoreProvider.class); if (!(EhcacheDatastoreProvider.class.isInstance(provider))) { throw new RuntimeException("Not testing with Ehcache, cannot extract underlying cache"); } return EhcacheDatastoreProvider.class.cast(provider); }
private static MapDatastoreProvider getProvider(SessionFactory sessionFactory) { DatastoreProvider provider = ((SessionFactoryImplementor) sessionFactory).getServiceRegistry().getService(DatastoreProvider.class); if (!(MapDatastoreProvider.class.isInstance(provider))) { throw new RuntimeException("Not testing with MapDatastoreProvider, cannot extract underlying map"); } return MapDatastoreProvider.class.cast(provider); }
@Override public AbstractRedisDialect getGridDialect(DatastoreProvider datastoreProvider) { return getDialect( (RedisDatastoreProvider) datastoreProvider ); }
protected RedisDatastoreProvider getProvider() { return (RedisDatastoreProvider) getSessionFactory() .getServiceRegistry() .getService( DatastoreProvider.class ); }
private RedisDatastoreProvider getProvider() { return (RedisDatastoreProvider) ( (SessionFactoryImplementor) sessions ) .getServiceRegistry() .getService( DatastoreProvider.class ); }
private RedisDatastoreProvider getProvider() { return (RedisDatastoreProvider) getSessionFactory() .getServiceRegistry() .getService( DatastoreProvider.class ); }
public static RedisJsonDialect getDialect(DatastoreProvider datastoreProvider) { return new RedisJsonDialect( (RedisDatastoreProvider) datastoreProvider ); }
@Override public GridDialect getGridDialect(DatastoreProvider datastoreProvider) { return new IgniteDialect( (IgniteDatastoreProvider) datastoreProvider ); }
@Bean public MongoTool mongoTool() { GridDialect dialect = gridDialect(); DatastoreProvider provider = datastoreProvider(); return new MongoTool(dialect, provider); }
@Autowired public MongoTool(GridDialect gridDialect, DatastoreProvider datastoreProvider) { this.gridDialect = gridDialect; this.datastoreProvider = datastoreProvider; }
/** DataStoreProvider 를 제공합니다. */ @Bean public DatastoreProvider datastoreProvider() { return (DatastoreProvider) getService(DatastoreProvider.class); }