private EntityTableObjectNameSource(String explicitName, String entityName) { this.explicitName = explicitName; this.logicalName = StringHelper.isNotEmpty( explicitName ) ? explicitName : StringHelper.unqualify( entityName ); }
private List<ConfigurationArtefactType> parsePrecedence(String s) { if ( StringHelper.isEmpty( s ) ) { return Collections.emptyList(); } StringTokenizer precedences = new StringTokenizer( s, ",; ", false ); List<ConfigurationArtefactType> tmpPrecedences = new ArrayList<ConfigurationArtefactType>(); while ( precedences.hasMoreElements() ) { tmpPrecedences.add( ConfigurationArtefactType.parsePrecedence( ( String ) precedences.nextElement() ) ); } return tmpPrecedences; }
public WrappedInferredData(PropertyData inferredData, String suffix) { this.wrappedInferredData = inferredData; this.propertyName = StringHelper.qualify( inferredData.getPropertyName(), suffix ); } }
public static String buildSafeClassName(String className, String defaultPackageName) { if ( className.indexOf( '.' ) < 0 && StringHelper.isNotEmpty( defaultPackageName ) ) { className = StringHelper.qualify( defaultPackageName, className ); } return className; }
public Table bind() { final String unquotedOwnerTable = StringHelper.unquote( ownerEntityTable ); final String unquotedAssocTable = StringHelper.unquote( associatedEntityTable ); StringHelper.unqualify( ownerEntity ) : unquotedOwnerTable; final ObjectNameSource nameSource = buildNameContext( ownerObjectName, unquotedAssocTable ); final boolean ownerEntityTableQuoted = StringHelper.isQuoted( ownerEntityTable ); final boolean associatedEntityTableQuoted = StringHelper.isQuoted( associatedEntityTable ); final ObjectNameNormalizer.NamingStrategyHelper namingStrategyHelper = new ObjectNameNormalizer.NamingStrategyHelper() { public String determineImplicitName(NamingStrategy strategy) {
private void overridesDefaultInSecondaryTable( SecondaryTable secTableAnn, XMLContext.Default defaults, List<SecondaryTable> secondaryTables ) { if ( secTableAnn != null ) { //handle default values if ( StringHelper.isNotEmpty( defaults.getCatalog() ) || StringHelper.isNotEmpty( defaults.getSchema() ) ) { AnnotationDescriptor annotation = new AnnotationDescriptor( SecondaryTable.class ); annotation.setValue( "name", secTableAnn.name() ); annotation.setValue( "schema", secTableAnn.schema() ); annotation.setValue( "catalog", secTableAnn.catalog() ); annotation.setValue( "uniqueConstraints", secTableAnn.uniqueConstraints() ); annotation.setValue( "pkJoinColumns", secTableAnn.pkJoinColumns() ); if ( StringHelper.isEmpty( (String) annotation.valueOf( "schema" ) ) && StringHelper.isNotEmpty( defaults.getSchema() ) ) { annotation.setValue( "schema", defaults.getSchema() ); } if ( StringHelper.isEmpty( (String) annotation.valueOf( "catalog" ) ) && StringHelper.isNotEmpty( defaults.getCatalog() ) ) { annotation.setValue( "catalog", defaults.getCatalog() ); } secondaryTables.add( (SecondaryTable) AnnotationFactory.create( annotation ) ); } else { secondaryTables.add( secTableAnn ); } } }
@Override public String logicalCollectionColumnName(String columnName, String propertyName, String referencedColumn) { return StringHelper.isNotEmpty( columnName ) ? columnName : propertyName + "_" + referencedColumn; }
public String propertyToColumnName(String propertyName) { return StringHelper.unqualify( propertyName ); }
private String getCondition(String cond, String name) { if ( BinderHelper.isDefault( cond ) ) { cond = mappings.getFilterDefinition( name ).getDefaultFilterCondition(); if ( StringHelper.isEmpty( cond ) ) { throw new AnnotationException( "no filter condition found for filter " + name + " in " + StringHelper.qualify( propertyHolder.getPath(), propertyName ) ); } } return cond; }
.normalizeIdentifierQuoting( propertyresult.column() ); String key = StringHelper.root( name ); ArrayList<String> intermediateResults = propertyResultsTmp.get( key ); if ( intermediateResults == null ) {
public static String[] replace(String templates[], String placeholder, String replacement) { String[] result = new String[templates.length]; for ( int i =0; i<templates.length; i++ ) { result[i] = replace( templates[i], placeholder, replacement );; } return result; }
protected void addColumnBinding(SimpleValue value) { if ( StringHelper.isEmpty( mappedBy ) ) { String unquotedLogColName = StringHelper.unquote( getLogicalColumnName() ); String unquotedRefColumn = StringHelper.unquote( getReferencedColumn() ); String logicalColumnName = getMappings().getNamingStrategy() .logicalCollectionColumnName( unquotedLogColName, getPropertyName(), unquotedRefColumn ); if ( StringHelper.isQuoted( getLogicalColumnName() ) || StringHelper.isQuoted( getLogicalColumnName() ) ) { logicalColumnName = StringHelper.quote( logicalColumnName ); } getMappings().addColumnBinding( logicalColumnName, getMappingColumn(), value.getTable() ); } }
Boolean isRefColumnQuoted = StringHelper.isQuoted( logicalReferencedColumn ); String unquotedLogicalReferenceColumn = isRefColumnQuoted ? StringHelper.unquote( logicalReferencedColumn ) : logicalReferencedColumn; String unquotedMappedbyTable = StringHelper.unquote( mappedByTableName ); final String ownerObjectName = JPA2ElementCollection && mappedByEntityName != null ? StringHelper.unqualify( mappedByEntityName ) : unquotedMappedbyTable; columnName = getMappings().getNamingStrategy().foreignKeyColumnName( mappedByPropertyName, if ( isRefColumnQuoted || StringHelper.isQuoted( mappedByTableName ) ) { columnName = StringHelper.quote( columnName ); String unquotedLogicalTableName = StringHelper.unquote( logicalTableName ); columnName = getMappings().getNamingStrategy().foreignKeyColumnName( getPropertyName(), if ( isRefColumnQuoted || StringHelper.isQuoted( logicalTableName ) ) { columnName = StringHelper.quote( columnName ); String unquotedLogicalTableName = StringHelper.unquote( logicalTableName ); columnName = getMappings().getNamingStrategy().joinKeyColumnName( unquotedLogicalReferenceColumn, if ( isRefColumnQuoted || StringHelper.isQuoted( logicalTableName ) ) { columnName = StringHelper.quote( columnName );
public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery) throws HibernateException { String[] xcols = criteriaQuery.getColumnsUsingProjection(criteria, propertyName); String[] ycols = criteriaQuery.getColumnsUsingProjection(criteria, otherPropertyName); String result = StringHelper.join( " and ", StringHelper.add(xcols, getOp(), ycols) ); if (xcols.length>1) result = '(' + result + ')'; return result; //TODO: get SQL rendering out of this package! }
public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery) throws HibernateException { String[] columns = criteriaQuery.getColumnsUsingProjection(criteria, propertyName); String singleValueParam = StringHelper.repeat( "?, ", columns.length-1 ) + "?"; if ( columns.length>1 ) singleValueParam = '(' + singleValueParam + ')'; String params = values.length>0 ? StringHelper.repeat( singleValueParam + ", ", values.length-1 ) + singleValueParam : ""; String cols = StringHelper.join(", ", columns); if ( columns.length>1 ) cols = '(' + cols + ')'; return cols + " in (" + params + ')'; }
/** * @see java.lang.Object#toString() */ public String toString() { return '(' + StringHelper.join( ' ' + op + ' ', criteria.iterator() ) + ')'; }
private void getJoinTable(List<Annotation> annotationList, Element tree, XMLContext.Default defaults) { Element subelement = tree == null ? null : tree.element( "join-table" ); final Class<JoinTable> annotationType = JoinTable.class; if ( subelement != null ) { //ignore java annotation, an element is defined AnnotationDescriptor annotation = new AnnotationDescriptor( annotationType ); copyStringAttribute( annotation, subelement, "name", false ); copyStringAttribute( annotation, subelement, "catalog", false ); if ( StringHelper.isNotEmpty( defaults.getCatalog() ) && StringHelper.isEmpty( (String) annotation.valueOf( "catalog" ) ) ) { annotation.setValue( "catalog", defaults.getCatalog() ); } copyStringAttribute( annotation, subelement, "schema", false ); if ( StringHelper.isNotEmpty( defaults.getSchema() ) && StringHelper.isEmpty( (String) annotation.valueOf( "schema" ) ) ) { annotation.setValue( "schema", defaults.getSchema() ); } buildUniqueConstraints( annotation, subelement ); annotation.setValue( "joinColumns", getJoinColumns( subelement, false ) ); annotation.setValue( "inverseJoinColumns", getJoinColumns( subelement, true ) ); annotationList.add( AnnotationFactory.create( annotation ) ); } }