List of usage examples for org.hibernate.internal.util.config ConfigurationHelper getInt
public static int getInt(String name, Map values, int defaultValue)
From source file:com.hazelcast.hibernate.CacheEnvironment.java
License:Open Source License
public static int getLockTimeoutInMillis(Properties props) { int timeout = -1; try {// w w w .java2s .c o m timeout = ConfigurationHelper.getInt(LOCK_TIMEOUT, props, -1); } catch (Exception e) { Logger.getLogger(CacheEnvironment.class).finest(e); } if (timeout < 0) { timeout = MAXIMUM_LOCK_TIMEOUT; } return timeout; }
From source file:com.hazelcast.hibernate4.CacheEnvironment.java
License:Open Source License
public static int getLockTimeoutInMillis(Properties props) { int timeout = -1; try {/*w w w. ja v a2 s .c om*/ timeout = ConfigurationHelper.getInt(LOCK_TIMEOUT, props, -1); } catch (Exception ignored) { } if (timeout < 0) { try { timeout = ConfigurationHelper.getInt(LOCK_TIMEOUT_SECONDS, props, -1) * 1000; } catch (Exception ignored) { } } if (timeout < 0) { timeout = MAXIMUM_LOCK_TIMEOUT; } return timeout; }
From source file:com.literatejava.hibernate.allocator.LinearBlockAllocator.java
License:Open Source License
public void configure(Type type, Properties params, Dialect dialect) { ObjectNameNormalizer normalizer = (ObjectNameNormalizer) params.get(IDENTIFIER_NORMALIZER); this.tableName = ConfigurationHelper.getString(ALLOC_TABLE, params, DEFAULT_TABLE); this.sequenceColumn = ConfigurationHelper.getString(SEQUENCE_COLUMN, params, DEFAULT_SEQUENCE_COLUMN); this.allocColumn = ConfigurationHelper.getString(ALLOC_COLUMN, params, DEFAULT_ALLOC_COLUMN); // get SequenceName; default to Entities' TableName. // -//from w ww . j a va2s. co m this.sequenceName = ConfigurationHelper.getString(SEQUENCE_NAME, params, params.getProperty(PersistentIdentifierGenerator.TABLE)); if (sequenceName == null) { throw new IdentifierGenerationException( "LinearBlockAllocator: '" + SEQUENCE_NAME + "' must be specified"); } this.blockSize = ConfigurationHelper.getInt(BLOCK_SIZE, params, DEFAULT_BLOCK_SIZE); if (blockSize < 1) { blockSize = 1; } // qualify Table Name, if necessary; // -- if (tableName.indexOf('.') < 0) { String schemaName = normalizer.normalizeIdentifierQuoting(params.getProperty(SCHEMA)); String catalogName = normalizer.normalizeIdentifierQuoting(params.getProperty(CATALOG)); this.tableName = Table.qualify(catalogName, schemaName, tableName); } // build SQL strings; // -- use appendLockHint(LockMode) for now, as that is how Hibernate's generators do it. // this.query = "select " + allocColumn + " from " + dialect.appendLockHint(LockMode.PESSIMISTIC_WRITE, tableName) + " where " + sequenceColumn + " = ?" + dialect.getForUpdateString(); this.update = "update " + tableName + " set " + allocColumn + " = ? where " + sequenceColumn + " = ? and " + allocColumn + " = ?"; // setup Return Type & Result Holder. // -- this.returnType = type; this.returnClass = type.getReturnedClass(); this.resultFactory = IdentifierGeneratorHelper.getIntegralDataTypeHolder(returnClass); // done. }
From source file:de.innovationgate.webgate.api.mysql.GaleraClusterTableGenerator.java
License:Open Source License
@Override public void configure(Type type, Properties params, Dialect dialect) throws MappingException { identifierType = type;// www . j a va 2 s. c o m tableName = determineGeneratorTableName(params, dialect); segmentColumnName = determineSegmentColumnName(params, dialect); valueColumnName = determineValueColumnName(params, dialect); segmentValue = determineSegmentValue(params); segmentValueLength = determineSegmentColumnSize(params); initialValue = determineInitialValue(params); incrementSize = determineIncrementSize(params); this.selectQuery = buildSelectQuery(dialect); this.updateQuery = buildUpdateQuery(); this.insertQuery = buildInsertQuery(); // if the increment size is greater than one, we prefer pooled optimization; but we // need to see if the user prefers POOL or POOL_LO... String defaultPooledOptimizerStrategy = ConfigurationHelper.getBoolean(Environment.PREFER_POOLED_VALUES_LO, params, false) ? OptimizerFactory.StandardOptimizerDescriptor.POOLED_LO.getExternalName() : OptimizerFactory.StandardOptimizerDescriptor.POOLED.getExternalName(); final String defaultOptimizerStrategy = incrementSize <= 1 ? OptimizerFactory.StandardOptimizerDescriptor.NONE.getExternalName() : defaultPooledOptimizerStrategy; final String optimizationStrategy = ConfigurationHelper.getString(OPT_PARAM, params, defaultOptimizerStrategy); optimizer = OptimizerFactory.buildOptimizer(optimizationStrategy, identifierType.getReturnedClass(), incrementSize, ConfigurationHelper.getInt(INITIAL_PARAM, params, -1)); }
From source file:de.innovationgate.webgate.api.mysql.GaleraClusterTableGenerator.java
License:Open Source License
/** * Determine the size of the {@link #getSegmentColumnName segment column} * <p/>/* w w w . j a v a 2 s . com*/ * Called during {@link #configure configuration}. * * @see #getSegmentValueLength() * @param params The params supplied in the generator config (plus some standard useful extras). * @return The size of the segment column */ protected int determineSegmentColumnSize(Properties params) { return ConfigurationHelper.getInt(SEGMENT_LENGTH_PARAM, params, DEF_SEGMENT_LENGTH); }
From source file:de.innovationgate.webgate.api.mysql.GaleraClusterTableGenerator.java
License:Open Source License
protected int determineInitialValue(Properties params) { return ConfigurationHelper.getInt(INITIAL_PARAM, params, DEFAULT_INITIAL_VALUE); }
From source file:de.innovationgate.webgate.api.mysql.GaleraClusterTableGenerator.java
License:Open Source License
protected int determineIncrementSize(Properties params) { return ConfigurationHelper.getInt(INCREMENT_PARAM, params, DEFAULT_INCREMENT_SIZE); }
From source file:ee.ria.xroad.opmonitordaemon.OperationalDataRecordManager.java
License:Open Source License
private static int getConfiguredBatchSize(Session session) { if (configuredBatchSize == 0) { Properties props = ((SessionFactoryImpl) session.getSessionFactory()).getProperties(); configuredBatchSize = ConfigurationHelper.getInt(Environment.STATEMENT_BATCH_SIZE, props, DEFAULT_BATCH_SIZE);//from w ww . j ava 2s.c o m log.debug("Configured JDBC batch size is {}", configuredBatchSize); } return configuredBatchSize; }
From source file:ee.ria.xroad.opmonitordaemon.OperationalDataTest.java
License:Open Source License
@Test public void insertBulkData() { // Delete all the previous records and check if the batch_size // configuration parameter does not screw anything up. deleteAll();// w w w .j av a2s. c o m Configuration conf = new Configuration(); int configuredBatchSize = ConfigurationHelper.getInt(Environment.STATEMENT_BATCH_SIZE, conf.getProperties(), -1); // Save the exact number of records that should go into one batch. // Flush to empty the internal cache of Hibernate. for (int i = 0; i < configuredBatchSize; i++) { OperationalDataRecord rec = fillMinimalOperationalData(); session.save(rec); if ((i + 1) % configuredBatchSize == 0) { session.flush(); session.clear(); } } assertEquals(selectCount(), configuredBatchSize); // Save two batches and some more. for (int i = 0; i < 2 * configuredBatchSize + 4; i++) { OperationalDataRecord rec = fillMinimalOperationalData(); session.save(rec); if ((i + 1) % configuredBatchSize == 0) { session.flush(); session.clear(); } } // Check that the expected number of records has been inserted. assertEquals(selectCount(), 3 * configuredBatchSize + 4); }
From source file:net.e6tech.elements.persist.hibernate.ModifiedTableGenerator.java
License:Apache License
@Override public void configure(Type type, Properties params, ServiceRegistry serviceRegistry) throws MappingException { identifierType = type;/*w w w . j a v a 2s.c om*/ final JdbcEnvironment jdbcEnvironment = serviceRegistry.getService(JdbcEnvironment.class); qualifiedTableName = determineGeneratorTableName(params, jdbcEnvironment); segmentColumnName = determineSegmentColumnName(params, jdbcEnvironment); valueColumnName = determineValueColumnName(params, jdbcEnvironment); segmentValue = determineSegmentValue(params); segmentValueLength = determineSegmentColumnSize(params); initialValue = determineInitialValue(params); incrementSize = determineIncrementSize(params); final String optimizationStrategy = ConfigurationHelper.getString(OPT_PARAM, params, OptimizerFactory.determineImplicitOptimizerName(incrementSize, params)); optimizer = OptimizerFactory.buildOptimizer(optimizationStrategy, identifierType.getReturnedClass(), incrementSize, ConfigurationHelper.getInt(INITIAL_PARAM, params, -1)); }