Hibernate ORM Configuration - 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 Configuration class.

This code example shows how to use the following methods:
		} 
		return cfg;
	} 
 
	protected Configuration createConfiguration() {
		return new Configuration();
	} 
	 
	/** 
	 *  
	 */ 
	protected void doConfiguration(Configuration configuration) {	
		validateParameters();		 
		 
		if (entityResolver != null) {
			try { 
				Class resolver = ReflectHelper.classForName(entityResolver, this.getClass());
				Object object = resolver.newInstance();
				 
				configuration.setEntityResolver((EntityResolver) object);
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:buildSessionFactory, configure, setProperty
	public static final Logger logger = Logger.getLogger(CloudSessionFactory.class);
	 
	private SessionFactory factory;
	 
	private CloudSessionFactory() { 
		Configuration cfg = new Configuration();
		File file = ConfigurationHelper.findConfigurationFile("hibernate.cfg.xml");
 
        File propertiesFile = ConfigurationHelper.findConfigurationFile("db.properties");
        Properties dbProp = null;
        String     dbName     = null;
        String     dbHost     = null;
        String     dbUser     = null;
        String     dbPassword = null;
        String     dbPort     = null; 
                
        if (null != propertiesFile) {
             
            if(EncryptionSecretKeyCheckerUtil.useEncryption()){ 
                StandardPBEStringEncryptor encryptor = EncryptionSecretKeyCheckerUtil.getEncryptor();

8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
			throw new IOException(e);
		} 
	} 
	 
	public SessionFactory buildSessionFactory() {
		Configuration config = new Configuration().configure();
		//H2 version we use behaves differently from H2Dialect in Hibernate so we provide our implementation 
		config.setProperty(Environment.DIALECT, H2LessStrictDialect.class.getName());
		config.setProperty(Environment.URL, connectionUrl);
		config.setProperty(Environment.DRIVER, "org.h2.Driver");
		config.setProperty(Environment.USER, "sa");
		config.setProperty(Environment.PASS, "sa");
		config.setProperty(Environment.USE_SECOND_LEVEL_CACHE, "false");
		config.setProperty(Environment.USE_QUERY_CACHE, "false");
		 
		//Let's validate HBMs against the actual schema 
		config.setProperty(Environment.HBM2DDL_AUTO, "validate");
		 
		return config.buildSessionFactory();
	} 
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:buildSessionFactory, configure, setProperty
	public static final Logger logger = Logger.getLogger(CloudStackSessionFactory.class);
	 
	private SessionFactory factory;
	 
	private CloudStackSessionFactory() { 
		Configuration cfg = new Configuration();
		File file = ConfigurationHelper.findConfigurationFile("CloudStack.cfg.xml");
 
        File propertiesFile = ConfigurationHelper.findConfigurationFile("db.properties");
        Properties dbProp = null;
        String     dbName     = null;
        String     dbHost     = null;
        String     dbUser     = null;
        String     dbPassword = null;
        String     dbPort     = null; 
                
        if (null != propertiesFile) {
             
            if(EncryptionSecretKeyCheckerUtil.useEncryption()){ 
                StandardPBEStringEncryptor encryptor = EncryptionSecretKeyCheckerUtil.getEncryptor();

8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:buildSessionFactory, configure
		return sessionFactory.getCurrentSession();
	} 
 
	private HibernateUtil() { 
		try { 
			Configuration configuration = new Configuration();
 
			configuration = configuration.configure();
 
			_sessionFactory = configuration.buildSessionFactory();
		} 
		catch (Exception e) {
			_log.error(e, e);
		} 
	} 
 
	private static Log _log = LogFactoryUtil.getLog(HibernateUtil.class);
 
	private static HibernateUtil _instance = new HibernateUtil();
 
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:addAnnotatedClass, buildSessionFactory, setProperty
			targetMethod = "inconsistentFieldConfiguration", 
			helper = "org.hibernate.search.testsupport.BytemanHelper", 
			action = "countInvocation()", 
			name = "testWarningLoggedForInconsistentFieldConfiguration") 
	public void testWarningLoggedForInconsistentFieldConfiguration() throws Exception {
		Configuration config = new Configuration();
		config.addAnnotatedClass( Product.class );
 
		config.setProperty( "hibernate.search.lucene_version", TestConstants.getTargetLuceneVersion().toString() );
		config.setProperty( "hibernate.search.default.directory_provider", "ram" );
		config.setProperty( "hibernate.search.default.indexBase", TestConstants.getIndexDirectory( TokenizationTest.class ) );
 
		config.buildSessionFactory();
 
		assertEquals( "Wrong invocation count", 1, BytemanHelper.getAndResetInvocationCount() ); 
	} 
 
	@Entity 
	@Indexed 
	public static class Product { 
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:setProperty
		super.testConcurrency(); 
	} 
 
	@Override 
	protected void configure(Configuration cfg) {
		super.configure( cfg );
		cfg.setProperty( "hibernate.search.worker.scope", "transaction" );
		cfg.setProperty( "hibernate.search.default.worker.execution", "async" );
		cfg.setProperty( "hibernate.search.default.worker.thread_pool.size", "1" );
		cfg.setProperty( "hibernate.search.default.worker.buffer_queue.max", "10" );
	} 
 
	@Override 
	protected boolean isWorkerSync() { 
		return false; 
	} 
} 
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:addAnnotatedClass, addProperties, buildSessionFactory
public class TestRunnerStandalone { 
 
	private final TestScenario scenario = TestScenarioFactory.create(); 
 
	private SessionFactory getSessionFactory() { 
		Configuration cfg = new Configuration(); 
		cfg.addAnnotatedClass( Author.class ); 
		cfg.addAnnotatedClass( Book.class ); 
		cfg.addProperties( getHibernateProperties() ); 
		return cfg.buildSessionFactory(); 
	} 
 
	private Properties getHibernateProperties() { 
		Properties properties = scenario.getHibernateProperties(); 
		setDefaultProperty( properties, "hibernate.dialect", "org.hibernate.dialect.H2Dialect" ); 
		setDefaultProperty( properties, "hibernate.connection.provider_class", "org.hibernate.hikaricp.internal.HikariCPConnectionProvider" ); 
		setDefaultProperty( properties, "hibernate.hikari.minimumPoolSize", "5" ); 
		setDefaultProperty( properties, "hibernate.hikari.maximumPoolSize", "20" ); 
		setDefaultProperty( properties, "hibernate.hikari.dataSourceClassName", "org.h2.jdbcx.JdbcDataSource" ); 
		setDefaultProperty( properties, "hibernate.hikari.dataSource.url", "jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;MULTI_THREADED=1" ); 
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
  private final static Log log = LogFactory.getLog(NodeConfiguration.class);
  private Node node; 
  private Properties overrides = new Properties();
 
  public NodeConfiguration(Node node){ 
    super(); 
    this.node = node;
  } 
 
  public NodeConfiguration(Node node, Properties overrides) {
    this.node = node;
    this.overrides = overrides;
  } 
 
  @Override 
  public Configuration configure() {
    super.configure(); 
    setProperty("hibernate.session_factory_name", "factory:"+node.getName());
		setProperty("hibernate.dialect", DialectTools.getHibernateDialect(node.getDialect()).getName());
		setProperty("hibernate.connection.driver_class", DriverLoader.getDriverClass(node.getDialect()));
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:addFile, buildMappings
		} 
		assertTrue("Class mapping should create Backref for this testcase", hasBackrefs);
	} 
	 
	public void testReadable() { 
        Configuration cfg = new Configuration();
 
        cfg.addFile(new File(getOutputDir(), getBaseForMappings() + "Car.hbm.xml"));
        cfg.addFile(new File(getOutputDir(), getBaseForMappings() + "CarPart.hbm.xml"));
         
        cfg.buildMappings();
    } 
 
	protected String getBaseForMappings() {
		return "org/hibernate/tool/hbm2x/hbm2hbmxml/"; 
	} 
 
	public static Test suite() {
		return new TestSuite(BackrefTest.class);
	} 
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
See Code Examples for Hibernate ORM Configuration Methods: