Hibernate ORM StandardServiceRegistryBuilder - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Hibernate ORM StandardServiceRegistryBuilder class.

This code example shows how to use the following methods:applySettings, build
	 
	List results = new ArrayList();
	 
	public void analyze(Configuration cfg) {
		 
		StandardServiceRegistryBuilder builder = new StandardServiceRegistryBuilder();
		builder.applySettings(cfg.getProperties());
		ServiceRegistry serviceRegistry = builder.build();
		Settings settings = cfg.buildSettings(serviceRegistry);
		 
		for (int i = 0; i < detectors.length; i++) {
			detectors[i].initialize( cfg, settings );
			detectors[i].visit(cfg, this);
		} 
					 
	} 
	 
	/* (non-Javadoc) 
	 * @see org.hibernate.tool.hbmlint.IssueCollector#reportProblem(org.hibernate.tool.hbmlint.Issue) 
	 */ 
7
CodeRank
This code example shows how to use the following methods:applySettings, build
		} 
				 
	} 
	 
	public void testReadSchemaIncremental() { 
		StandardServiceRegistryBuilder builder = new StandardServiceRegistryBuilder();
		builder.applySettings(cfg.getProperties());
		ServiceRegistry serviceRegistry = builder.build();
 
		Settings buildSettings = cfg.buildSettings(serviceRegistry);
 
		TableSelectorStrategy tss = new TableSelectorStrategy(new DefaultReverseEngineeringStrategy());
		MockedMetaDataDialect mockedMetaDataDialect = new MockedMetaDataDialect();
		JDBCReader reader = JDBCReaderFactory.newJDBCReader( buildSettings, tss, mockedMetaDataDialect, serviceRegistry);
		 
		tss.addSchemaSelection( new SchemaSelection(null,null, "CHILD") );
		 
		DatabaseCollector dc = new DefaultDatabaseCollector(reader.getMetaDataDialect());
		reader.readDatabaseSchema( dc, null, null );
		 
6
CodeRank
This code example shows how to use the following methods:applySettings, build
		} 
	} 
 
	private OverrideRepository buildOverrideRepository() { 
		if(settings==null) {
			StandardServiceRegistryBuilder builder = new StandardServiceRegistryBuilder();
			//builder.configure(); 
			builder.applySettings(Environment.getProperties());
			ServiceRegistry serviceRegistry = builder.build();
			 
			settings = new SettingsFactory() {
				// trick to get hibernate.properties settings for defaultschema/catalog in here 
			}.buildSettings(Environment.getProperties(), serviceRegistry);
		} 
		//return new OverrideRepository(settings.getDefaultCatalogName(),settings.getDefaultSchemaName()); 
		return new OverrideRepository(); 
	} 
	 
	protected String[] getCreateSQL() {
		return new String[] {
6
CodeRank
This code example shows how to use the following methods:
 
	@BeforeClass 
	public static void geraBanco(){ 
		Configuration cfg = new Configuration();
		cfg.addAnnotatedClass(PessoaFisica.class);
		ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().applySettings(cfg.getProperties()).build();        
        factory = cfg.buildSessionFactory(serviceRegistry);
	} 
	 
	@Test
	public void shouldSaveAndLoadEntityMappedWithCpfUserType(){ 
		Session session = factory.openSession();
		Transaction transaction = session.beginTransaction();
		PessoaFisica pessoa = new PessoaFisica();
		CPF cpf = new CPF("555.555.555-55");
		pessoa.setCpf(cpf);
		session.save(pessoa);
		transaction.commit();
		session.flush();
		session.close();
6
CodeRank
This code example shows how to use the following methods:applySettings, build
 
	} 
 
	public void initialize(Configuration cfg, Settings settings) {
		super.initialize( cfg, settings );
		StandardServiceRegistryBuilder builder = new StandardServiceRegistryBuilder();
		builder.applySettings(cfg.getProperties());
		ServiceRegistry serviceRegistry = builder.build();
		 
		dialect = serviceRegistry.getService(JdbcServices.class).getDialect();
 
		tableSelector = new TableSelectorStrategy(
				new DefaultReverseEngineeringStrategy() ); 
		reader = JDBCReaderFactory.newJDBCReader( cfg.getProperties(),
				settings, tableSelector, serviceRegistry);
		dbc = new DefaultDatabaseCollector(reader.getMetaDataDialect());
		mapping = cfg.buildMapping();
	} 
 
	public void visit(Configuration cfg, IssueCollector collector) {
6
CodeRank
This code example shows how to use the following methods:build
	 * use the same quotes as JDBCReader. 
	 * Because of this there are 2 opposite methods(and they are both failed as addTable uses quoted names 
	 * but getTable uses non-quoted names ) 
	 */ 
	public void testQuotedNamesAndDefaultDatabaseCollector() { 
		StandardServiceRegistryBuilder builder = new StandardServiceRegistryBuilder();
		ServiceRegistry serviceRegistry = builder.build();
		Settings buildSettings = cfg.buildSettings(serviceRegistry);
				 
		MetaDataDialect realMetaData = JDBCReaderFactory.newMetaDataDialect( serviceRegistry.getService(JdbcServices.class).getDialect(), cfg.getProperties() );
		 
		JDBCReader reader = JDBCReaderFactory.newJDBCReader( buildSettings, new DefaultReverseEngineeringStrategy(), realMetaData, serviceRegistry );
		 
		DatabaseCollector dc = new DefaultDatabaseCollector(reader.getMetaDataDialect());
		reader.readDatabaseSchema( dc, null, SCHEMA );
		 
		assertNotNull("The table should be found", dc.getTable(SCHEMA, null, TABLE1));
		assertNotNull("The table should be found", dc.getTable(SCHEMA, null, TABLE2));
		assertNull("Quoted names should not return the table", dc.getTable(quote(SCHEMA), null, QTABLE1));
		assertNull("Quoted names should not return the table", dc.getTable(quote(SCHEMA), null, QTABLE2));
6
CodeRank
This code example shows how to use the following methods:build
		 
	} 
	 
	public void testCachedDialect() { 
		 
		StandardServiceRegistryBuilder builder = new StandardServiceRegistryBuilder();
		ServiceRegistry serviceRegistry = builder.build();
		Settings buildSettings = cfg.buildSettings(serviceRegistry);
				 
		MetaDataDialect realMetaData = JDBCReaderFactory.newMetaDataDialect( serviceRegistry.getService(JdbcServices.class).getDialect(), cfg.getProperties() );
		 
		MockedMetaDataDialect mock = new MockedMetaDataDialect(realMetaData);
		CachedMetaDataDialect dialect = new CachedMetaDataDialect(mock);
		 
		JDBCReader reader = JDBCReaderFactory.newJDBCReader( buildSettings, new DefaultReverseEngineeringStrategy(), dialect, serviceRegistry );
		 
		DatabaseCollector dc = new DefaultDatabaseCollector(reader.getMetaDataDialect());
		reader.readDatabaseSchema( dc, null, null );
 
		validate( dc );		
6
CodeRank
This code example shows how to use the following methods:
 
	protected void tearDown() throws Exception {
		Statement statement = null;
		Connection con = null;
		Settings settings = null;
		ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder()
			.applySettings( getConfiguration().getProperties() )
			.build(); 
    	 
        try { 
        	settings = getConfiguration().buildSettings(serviceRegistry);
        	con = serviceRegistry.getService(JdbcServices.class).getConnectionProvider().getConnection();
        	statement = con.createStatement();
        	statement.execute("drop table Session_attributes");
        	statement.execute("drop table Users");
        	statement.execute("drop table Groups");
        	con.commit();
        } finally { 
        	if (statement!=null) statement.close();
        	serviceRegistry.getService(JdbcServices.class).getConnectionProvider().closeConnection(con);
5
CodeRank
See Code Examples for Hibernate ORM StandardServiceRegistryBuilder Methods: