本文整理汇总了Java中org.hibernate.util.StringHelper.isEmpty方法的典型用法代码示例。如果您正苦于以下问题:Java StringHelper.isEmpty方法的具体用法?Java StringHelper.isEmpty怎么用?Java StringHelper.isEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.hibernate.util.StringHelper
的用法示例。
在下文中一共展示了StringHelper.isEmpty方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseFilterDef
import org.hibernate.util.StringHelper; //导入方法依赖的package包/类
private static void parseFilterDef(Element element, Mappings mappings) {
String name = element.attributeValue( "name" );
log.debug( "Parsing filter-def [" + name + "]" );
String defaultCondition = element.getTextTrim();
if ( StringHelper.isEmpty( defaultCondition ) ) {
defaultCondition = element.attributeValue( "condition" );
}
HashMap paramMappings = new HashMap();
Iterator params = element.elementIterator( "filter-param" );
while ( params.hasNext() ) {
final Element param = (Element) params.next();
final String paramName = param.attributeValue( "name" );
final String paramType = param.attributeValue( "type" );
log.debug( "adding filter parameter : " + paramName + " -> " + paramType );
final Type heuristicType = TypeFactory.heuristicType( paramType );
log.debug( "parameter heuristic type : " + heuristicType );
paramMappings.put( paramName, heuristicType );
}
log.debug( "Parsed filter-def [" + name + "]" );
FilterDefinition def = new FilterDefinition( name, defaultCondition, paramMappings );
mappings.addFilterDefinition( def );
}
示例2: parseFilter
import org.hibernate.util.StringHelper; //导入方法依赖的package包/类
private static void parseFilter(Element filterElement, Filterable filterable, Mappings model) {
final String name = filterElement.attributeValue( "name" );
String condition = filterElement.getTextTrim();
if ( StringHelper.isEmpty(condition) ) {
condition = filterElement.attributeValue( "condition" );
}
//TODO: bad implementation, cos it depends upon ordering of mapping doc
// fixing this requires that Collection/PersistentClass gain access
// to the Mappings reference from Configuration (or the filterDefinitions
// map directly) sometime during Configuration.buildSessionFactory
// (after all the types/filter-defs are known and before building
// persisters).
if ( StringHelper.isEmpty(condition) ) {
condition = model.getFilterDefinition(name).getDefaultFilterCondition();
}
if ( condition==null) {
throw new MappingException("no filter condition found for filter: " + name);
}
log.debug( "Applying filter [" + name + "] as [" + condition + "]" );
filterable.addFilter( name, condition );
}
示例3: bindReturn
import org.hibernate.util.StringHelper; //导入方法依赖的package包/类
private static NativeSQLQueryRootReturn bindReturn(Element returnElem, Mappings mappings, int elementCount) {
String alias = returnElem.attributeValue( "alias" );
if( StringHelper.isEmpty(alias)) {
alias = "alias_" + elementCount; // hack/workaround as sqlquery impl depend on having a key.
}
String entityName = HbmBinder.getEntityName(returnElem, mappings);
if(entityName==null) {
throw new MappingException( "<return alias='" + alias + "'> must specify either a class or entity-name");
}
LockMode lockMode = getLockMode( returnElem.attributeValue( "lock-mode" ) );
PersistentClass pc = mappings.getClass( entityName );
java.util.Map propertyResults = bindPropertyResults(alias, returnElem, pc, mappings );
return new NativeSQLQueryRootReturn(
alias,
entityName,
propertyResults,
lockMode
);
}
示例4: getPojoPropertyAccessor
import org.hibernate.util.StringHelper; //导入方法依赖的package包/类
/**
* Retreives a PropertyAccessor specific for a PojoRepresentation with the given access strategy.
*
* @param pojoAccessorStrategy The access strategy.
* @return An appropriate accessor.
*/
private static PropertyAccessor getPojoPropertyAccessor(String pojoAccessorStrategy) {
if ( StringHelper.isEmpty( pojoAccessorStrategy ) || "property".equals( pojoAccessorStrategy ) ) {
return BASIC_PROPERTY_ACCESSOR;
}
else if ( "field".equals( pojoAccessorStrategy ) ) {
return DIRECT_PROPERTY_ACCESSOR;
}
else if ( "embedded".equals( pojoAccessorStrategy ) ) {
return EMBEDDED_PROPERTY_ACCESSOR;
}
else if ( "noop".equals(pojoAccessorStrategy) ) {
return NOOP_ACCESSOR;
}
else {
return resolveCustomAccessor( pojoAccessorStrategy );
}
}
示例5: configure
import org.hibernate.util.StringHelper; //导入方法依赖的package包/类
public void configure(Configuration cfg) {
super.configure( cfg );
if ( !useAntlrParser ) {
cfg.setProperty( Environment.QUERY_TRANSLATOR, ClassicQueryTranslatorFactory.class.getName() );
try {
String dialectTrueRepresentation = Dialect.getDialect().toBooleanValueString( true );
// if this call succeeds, then the dialect is saying to represent true/false as int values...
Integer.parseInt( dialectTrueRepresentation );
String subs = cfg.getProperties().getProperty( Environment.QUERY_SUBSTITUTIONS );
if ( subs == null ) {
subs = "";
}
if ( StringHelper.isEmpty( subs ) ) {
subs = "true=1, false=0";
}
else {
subs += ", true=1, false=0";
}
cfg.getProperties().setProperty( Environment.QUERY_SUBSTITUTIONS, subs );
}
catch( NumberFormatException nfe ) {
// the Integer#parseInt call failed...
}
}
}
示例6: getConfigFilePath
import org.hibernate.util.StringHelper; //导入方法依赖的package包/类
public static String getConfigFilePath(Properties props) {
String configResourcePath = PropertiesHelper.getString(CacheEnvironment.CONFIG_FILE_PATH_LEGACY, props, null);
if (StringHelper.isEmpty(configResourcePath)) {
configResourcePath = PropertiesHelper.getString(CacheEnvironment.CONFIG_FILE_PATH, props, null);
}
return configResourcePath;
}
示例7: configure
import org.hibernate.util.StringHelper; //导入方法依赖的package包/类
public void configure(Type type, Properties params, Dialect dialect) throws MappingException {
tableName = PropertiesHelper.getString( TABLE_PARAM, params, DEF_TABLE );
if ( tableName.indexOf( '.' ) < 0 ) {
String schemaName = params.getProperty( SCHEMA );
String catalogName = params.getProperty( CATALOG );
tableName = Table.qualify( catalogName, schemaName, tableName );
}
segmentColumnName = PropertiesHelper.getString( SEGMENT_COLUMN_PARAM, params, DEF_SEGMENT_COLUMN );
segmentValue = params.getProperty( SEGMENT_VALUE_PARAM );
if ( StringHelper.isEmpty( segmentValue ) ) {
log.debug( "explicit segment value for id generator [" + tableName + '.' + segmentColumnName + "] suggested; using default [" + DEF_SEGMENT_VALUE + "]" );
segmentValue = DEF_SEGMENT_VALUE;
}
segmentValueLength = PropertiesHelper.getInt( SEGMENT_LENGTH_PARAM, params, DEF_SEGMENT_LENGTH );
valueColumnName = PropertiesHelper.getString( VALUE_COLUMN_PARAM, params, DEF_VALUE_COLUMN );
initialValue = PropertiesHelper.getInt( INITIAL_PARAM, params, DEFAULT_INITIAL_VALUE );
incrementSize = PropertiesHelper.getInt( INCREMENT_PARAM, params, DEFAULT_INCREMENT_SIZE );
identifierType = type;
String query = "select " + valueColumnName +
" from " + tableName + " tbl" +
" where tbl." + segmentColumnName + "=?";
HashMap lockMap = new HashMap();
lockMap.put( "tbl", LockMode.UPGRADE );
this.query = dialect.applyLocksToSql( query, lockMap, CollectionHelper.EMPTY_MAP );
update = "update " + tableName +
" set " + valueColumnName + "=? " +
" where " + valueColumnName + "=? and " + segmentColumnName + "=?";
insert = "insert into " + tableName + " (" + segmentColumnName + ", " + valueColumnName + ") " + " values (?,?)";
String defOptStrategy = incrementSize <= 1 ? OptimizerFactory.NONE : OptimizerFactory.POOL;
String optimizationStrategy = PropertiesHelper.getString( OPT_PARAM, params, defOptStrategy );
optimizer = OptimizerFactory.buildOptimizer( optimizationStrategy, identifierType.getReturnedClass(), incrementSize );
}
示例8: start
import org.hibernate.util.StringHelper; //导入方法依赖的package包/类
/**
* Callback to perform any necessary initialization of the underlying cache implementation during SessionFactory
* construction.
*
* @param properties current configuration settings.
*/
public final void start(Properties properties) throws CacheException {
String jndiNamespace = properties.getProperty( Environment.CACHE_NAMESPACE );
if ( StringHelper.isEmpty( jndiNamespace ) ) {
throw new CacheException( "No JNDI namespace specified for cache" );
}
cache = locateCache( jndiNamespace, NamingHelper.getJndiProperties( properties ) );
prepare( properties );
}
示例9: start
import org.hibernate.util.StringHelper; //导入方法依赖的package包/类
/**
* Callback to perform any necessary initialization of the underlying cache implementation
* during SessionFactory construction.
*
* @param properties current configuration settings.
*/
public void start(Properties properties) throws CacheException {
if (manager != null) {
log.warn("Attempt to restart an already started EhCacheProvider. Use sessionFactory.close() " +
" between repeated calls to buildSessionFactory. Using previously created EhCacheProvider." +
" If this behaviour is required, consider using net.sf.ehcache.hibernate.SingletonEhCacheProvider.");
return;
}
try {
String configurationResourceName = null;
if (properties != null) {
configurationResourceName = (String) properties.get( Environment.CACHE_PROVIDER_CONFIG );
}
if ( StringHelper.isEmpty( configurationResourceName ) ) {
manager = new CacheManager();
} else {
URL url = loadResource(configurationResourceName);
manager = new CacheManager(url);
}
} catch (net.sf.ehcache.CacheException e) {
//yukky! Don't you have subclasses for that!
//TODO race conditions can happen here
if (e.getMessage().startsWith("Cannot parseConfiguration CacheManager. Attempt to create a new instance of " +
"CacheManager using the diskStorePath")) {
throw new CacheException("Attempt to restart an already started EhCacheProvider. Use sessionFactory.close() " +
" between repeated calls to buildSessionFactory. Consider using net.sf.ehcache.hibernate.SingletonEhCacheProvider."
, e );
} else {
throw e;
}
}
}
示例10: initialize
import org.hibernate.util.StringHelper; //导入方法依赖的package包/类
public void initialize(Token tok) {
super.initialize(tok);
filename = tok.getFilename();
line = tok.getLine();
column = tok.getColumn();
String text = tok.getText();
textLength = StringHelper.isEmpty(text) ? 0 : text.length();
}
示例11: bindManyToManySubelements
import org.hibernate.util.StringHelper; //导入方法依赖的package包/类
private static void bindManyToManySubelements(
Collection collection,
Element manyToManyNode,
Mappings model) throws MappingException {
// Bind the where
Attribute where = manyToManyNode.attribute( "where" );
String whereCondition = where == null ? null : where.getValue();
collection.setManyToManyWhere( whereCondition );
// Bind the order-by
Attribute order = manyToManyNode.attribute( "order-by" );
String orderFragment = order == null ? null : order.getValue();
collection.setManyToManyOrdering( orderFragment );
// Bind the filters
Iterator filters = manyToManyNode.elementIterator( "filter" );
if ( ( filters.hasNext() || whereCondition != null ) &&
collection.getFetchMode() == FetchMode.JOIN &&
collection.getElement().getFetchMode() != FetchMode.JOIN ) {
throw new MappingException(
"many-to-many defining filter or where without join fetching " +
"not valid within collection using join fetching [" + collection.getRole() + "]"
);
}
while ( filters.hasNext() ) {
final Element filterElement = ( Element ) filters.next();
final String name = filterElement.attributeValue( "name" );
String condition = filterElement.getTextTrim();
if ( StringHelper.isEmpty(condition) ) condition = filterElement.attributeValue( "condition" );
if ( StringHelper.isEmpty(condition) ) {
condition = model.getFilterDefinition(name).getDefaultFilterCondition();
}
if ( condition==null) {
throw new MappingException("no filter condition found for filter: " + name);
}
log.debug(
"Applying many-to-many filter [" + name +
"] as [" + condition +
"] to role [" + collection.getRole() + "]"
);
collection.addManyToManyFilter( name, condition );
}
}