Java 类org.hibernate.ogm.datastore.spi.DatastoreProvider 实例源码

项目:debop4j    文件:LoadSelectedColumnsGlobalTest.java   
/**
 * 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);
}
项目:hibernate-ogm-redis    文件:RedisTestHelper.java   
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 );
}
项目:hibernate-ogm-redis    文件:RedisModuleMemberRegistrationWithTTLConfiguredIT.java   
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 );
    }
项目:hibernate-ogm-ignite    文件:IgniteCacheInitializer.java   
@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 );
    }
}
项目:hibernate-ogm-ignite    文件:IgniteTestHelper.java   
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;
}
项目:debop4j    文件:MongoDBTestHelper.java   
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);
}
项目:debop4j    文件:LoadSelectedColumnsCollectionTest.java   
@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);
    }
项目:debop4j    文件:LoadSelectedColumnsCollectionTest.java   
/**
 * 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);
}
项目:debop4j    文件:LoadSelectedColumnsInEntityTest.java   
@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);
}
项目:debop4j    文件:EhcacheGridDatastoreConfigBase.java   
@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);
}
项目:debop4j    文件:EhcacheTestHelper.java   
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);
}
项目:debop4j    文件:HashMapTestHelper.java   
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);
}
项目:hibernate-ogm-redis    文件:RedisTestHelper.java   
@Override
public AbstractRedisDialect getGridDialect(DatastoreProvider datastoreProvider) {
    return getDialect( (RedisDatastoreProvider) datastoreProvider );
}
项目:hibernate-ogm-redis    文件:RedisOgmTestCase.java   
protected RedisDatastoreProvider getProvider() {
    return (RedisDatastoreProvider) getSessionFactory()
            .getServiceRegistry()
            .getService( DatastoreProvider.class );
}
项目:hibernate-ogm-redis    文件:TTLConfiguredProgrammaticallyTest.java   
private RedisDatastoreProvider getProvider() {
    return (RedisDatastoreProvider) ( (SessionFactoryImplementor) sessions )
            .getServiceRegistry()
            .getService( DatastoreProvider.class );
}
项目:hibernate-ogm-redis    文件:ManyToOneInEntityJsonRepresentationTest.java   
private RedisDatastoreProvider getProvider() {
    return (RedisDatastoreProvider) getSessionFactory()
            .getServiceRegistry()
            .getService( DatastoreProvider.class );
}
项目:hibernate-ogm-redis    文件:TableGeneratorTest.java   
private RedisDatastoreProvider getProvider() {
    return (RedisDatastoreProvider) getSessionFactory()
            .getServiceRegistry()
            .getService( DatastoreProvider.class );
}
项目:hibernate-ogm-redis    文件:RedisModuleMemberRegistrationWithTTLConfiguredIT.java   
public static RedisJsonDialect getDialect(DatastoreProvider datastoreProvider) {
    return new RedisJsonDialect( (RedisDatastoreProvider) datastoreProvider );
}
项目:hibernate-ogm-ignite    文件:IgniteTestHelper.java   
@Override
public GridDialect getGridDialect(DatastoreProvider datastoreProvider) {
    return new IgniteDialect( (IgniteDatastoreProvider) datastoreProvider );
}
项目:debop4j    文件:MongoGridDatastoreConfigBase.java   
@Bean
public MongoTool mongoTool() {
    GridDialect dialect = gridDialect();
    DatastoreProvider provider = datastoreProvider();
    return new MongoTool(dialect, provider);
}
项目:debop4j    文件:MongoTool.java   
@Autowired
public MongoTool(GridDialect gridDialect, DatastoreProvider datastoreProvider) {
    this.gridDialect = gridDialect;
    this.datastoreProvider = datastoreProvider;
}
项目:debop4j    文件:GridDatastoreConfigBase.java   
/** DataStoreProvider 를 제공합니다. */
@Bean
public DatastoreProvider datastoreProvider() {
    return (DatastoreProvider) getService(DatastoreProvider.class);
}