Tabnine Logo
NamingStrategy
Code IndexAdd Tabnine to your IDE (free)

How to use
NamingStrategy
in
org.hibernate.cfg

Best Java code snippets using org.hibernate.cfg.NamingStrategy (Showing top 20 results out of 315)

origin: org.hibernate/hibernate-annotations

public void redefineColumnName(String columnName, String propertyName, boolean applyNamingStrategy) {
  if ( applyNamingStrategy ) {
    if ( StringHelper.isEmpty( columnName ) ) {
      if ( propertyName != null ) {
        mappingColumn.setName(
            mappings.getObjectNameNormalizer().normalizeIdentifierQuoting(
                mappings.getNamingStrategy().propertyToColumnName( propertyName )
            )
        );
      }
      //Do nothing otherwise
    }
    else {
      columnName = mappings.getObjectNameNormalizer().normalizeIdentifierQuoting( columnName );
      columnName = mappings.getNamingStrategy().columnName( columnName );
      columnName = mappings.getObjectNameNormalizer().normalizeIdentifierQuoting( columnName );
      mappingColumn.setName( columnName );
    }
  }
  else {
    if ( StringHelper.isNotEmpty( columnName ) ) {
      mappingColumn.setName( mappings.getObjectNameNormalizer().normalizeIdentifierQuoting( columnName ) );
    }
  }
}
origin: org.hibernate/hibernate-annotations

public String determineImplicitName(NamingStrategy strategy) {
  return strategy.classToTableName( entityName );
}
origin: org.hibernate/hibernate-annotations

  public String handleExplicitName(NamingStrategy strategy, String name) {
    return strategy.tableName( name );
  }
};
origin: stackoverflow.com

 NamingStrategy namingStrategy = new DefaultNamingStrategy();
String yourPropertyName="fooBar";
String columnName = namingStrategy.propertyToColumnName(yourPropertyName);
origin: hibernate/hibernate

private static String getClassTableName(PersistentClass model, Element node, Mappings mappings) {
  Attribute tableNameNode = node.attribute( "table" );
  if ( tableNameNode == null ) {
    return mappings.getNamingStrategy().classToTableName( model.getEntityName() );
  }
  else {
    return mappings.getNamingStrategy().tableName( tableNameNode.getValue() );
  }
}
origin: org.hibernate/com.springsource.org.hibernate

    bindColumn( columnElement, column, isNullable );
    final String columnName = columnElement.attributeValue( "name" );
    String logicalColumnName = mappings.getNamingStrategy().logicalColumnName(
        columnName, propertyPath
    );
    column.setName( mappings.getNamingStrategy().columnName(
      columnName ) );
    if ( table != null ) {
String logicalColumnName = mappings.getNamingStrategy().logicalColumnName(
    columnName, propertyPath
);
column.setName( mappings.getNamingStrategy().columnName( columnName ) );
if ( table != null ) {
column.setValue( simpleValue );
bindColumn( node, column, isNullable );
column.setName( mappings.getNamingStrategy().propertyToColumnName( propertyPath ) );
String logicalName = mappings.getNamingStrategy().logicalColumnName( null, propertyPath );
mappings.addColumnBinding( logicalName, column, table );
origin: org.grails/grails-datastore-gorm-hibernate-core

protected String getDefaultColumnName(PersistentProperty property, String sessionFactoryBeanName) {
  NamingStrategy namingStrategy = getNamingStrategy(sessionFactoryBeanName);
  String columnName = namingStrategy.propertyToColumnName(property.getName());
  if (property instanceof Association) {
    Association association = (Association) property;
    boolean isBasic = property instanceof Basic;
    if(isBasic && ((PropertyConfig)property.getMapping().getMappedForm()).getType() != null ) {
      return columnName;
    }
    if (isBasic) {
      return getForeignKeyForPropertyDomainClass(property, sessionFactoryBeanName);
    }
    if (property instanceof ManyToMany) {
      return getForeignKeyForPropertyDomainClass(property, sessionFactoryBeanName);
    }
    if (!association.isBidirectional() && association instanceof org.grails.datastore.mapping.model.types.OneToMany) {
      String prefix = namingStrategy.classToTableName(property.getOwner().getName());
      return addUnderscore(prefix, columnName) + FOREIGN_KEY_SUFFIX;
    }
    if (property.isInherited() && isBidirectionalManyToOne(property)) {
      return namingStrategy.propertyToColumnName(property.getOwner().getName()) + '_'+ columnName + FOREIGN_KEY_SUFFIX;
    }
    return columnName + FOREIGN_KEY_SUFFIX;
  }
  return columnName;
}
origin: org.hibernate/com.springsource.org.hibernate

String tableName;
if ( tableNode != null ) {
  tableName = mappings.getNamingStrategy().tableName( tableNode.getValue() );
  tableName = mappings.getNamingStrategy().collectionTableName(
      collection.getOwner().getEntityName(),
      logicalOwnerTableName ,
origin: jboss.jboss-embeddable-ejb3/hibernate-all

public Table bind() {
  //logicalName only accurate for assoc table...
  String logicalName = mappings.getNamingStrategy()
      .logicalCollectionTableName(
          name,
          ownerEntityTable == null ? null : ownerEntityTable.getName(), //we remove potential quotes
          associatedEntityTable == null ? null : associatedEntityTable.getName(), //we remove potential quotes
          propertyName );
  String extendedName = name != null ?
      mappings.getNamingStrategy().tableName( name ) :
      mappings.getNamingStrategy()
          .collectionTableName(
              ownerEntity,
              ownerEntityTable == null ? null : ownerEntityTable.getName(), //we remove potential quotes
              associatedEntity,
              associatedEntityTable == null ? null : associatedEntityTable.getName(), //we remove potential quotes 
              propertyName
          );
  return fillTable(
      schema, catalog,
      extendedName, logicalName, isAbstract, uniqueConstraints, constraints,
      denormalizedSuperTable, mappings
  );
}
origin: org.hibernate/hibernate-annotations

@Override
public void redefineColumnName(String columnName, String propertyName, boolean applyNamingStrategy) {
  if ( StringHelper.isNotEmpty( columnName ) ) {
    getMappingColumn().setName(
        applyNamingStrategy ?
            getMappings().getNamingStrategy().columnName( columnName ) :
            columnName
    );
  }
}
origin: org.hibernate/hibernate-annotations

final String ownerObjectName = JPA2ElementCollection && mappedByEntityName != null ?
  StringHelper.unqualify( mappedByEntityName ) : unquotedMappedbyTable;
columnName = getMappings().getNamingStrategy().foreignKeyColumnName(
    mappedByPropertyName,
    mappedByEntityName,
String logicalTableName = getMappings().getLogicalTableName( referencedEntity.getTable() );
String unquotedLogicalTableName = StringHelper.unquote( logicalTableName );
columnName = getMappings().getNamingStrategy().foreignKeyColumnName(
    getPropertyName(),
    referencedEntity.getEntityName(),
columnName = getMappings().getNamingStrategy().joinKeyColumnName(
    unquotedLogicalReferenceColumn,
    unquotedLogicalTableName
origin: org.hibernate/hibernate-annotations

public String determineImplicitName(NamingStrategy strategy) {
  final String strategyResult = strategy.collectionTableName(
      ownerEntity,
      ownerObjectName,
      associatedEntity,
      unquotedAssocTable,
      propertyName
  );
  return ownerEntityTableQuoted || associatedEntityTableQuoted
      ? StringHelper.quote( strategyResult )
      : strategyResult;
}
origin: hibernate/hibernate

String tableName;
if ( tableNode != null ) {
  tableName = mappings.getNamingStrategy().tableName( tableNode.getValue() );
  tableName = mappings.getNamingStrategy().propertyToTableName( className, path );
origin: org.hibernate/hibernate-annotations

protected void addColumnBinding(SimpleValue value) {
  String logicalColumnName = mappings.getNamingStrategy()
      .logicalColumnName( this.logicalColumnName, propertyName );
  mappings.addColumnBinding( logicalColumnName, getMappingColumn(), value.getTable() );
}
origin: org.hibernate/hibernate-annotations

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() );
  }
}
origin: org.hibernate/hibernate-annotations

private ObjectNameSource buildNameContext(String unquotedOwnerTable, String unquotedAssocTable) {
  String logicalName = mappings.getNamingStrategy().logicalCollectionTableName(
      name,
      unquotedOwnerTable,
      unquotedAssocTable,
      propertyName
  );
  if ( StringHelper.isQuoted( ownerEntityTable ) || StringHelper.isQuoted( associatedEntityTable ) ) {
    logicalName = StringHelper.quote( logicalName );
  }
  return new AssociationTableNameSource( name, logicalName );
}
origin: v-ladynev/fluent-hibernate

@Override
public Identifier determineJoinColumnName(ImplicitJoinColumnNameSource source) {
  String propertyName = getPropertyName(source.getAttributePath());
  String propertyEntityName = source.getEntityNaming().getEntityName();
  String propertyTableName = NamingStrategyUtils.unqualifyEntityName(propertyEntityName);
  String referencedColumnName = source.getReferencedColumnName().getText();
  String result = hibernate4Strategy.foreignKeyColumnName(propertyName, propertyEntityName,
      propertyTableName, referencedColumnName);
  return toIdentifier(result, source.getBuildingContext());
}
origin: org.grails/grails-hibernate

private static String getForeignKeyForPropertyDomainClass(GrailsDomainClassProperty property,
    String sessionFactoryBeanName) {
  final String propertyName = property.getDomainClass().getPropertyName();
 NamingStrategy namingStrategy = getNamingStrategy(sessionFactoryBeanName);
  return namingStrategy.propertyToColumnName(propertyName) + FOREIGN_KEY_SUFFIX;
}
origin: org.hibernate/com.springsource.org.hibernate.core

private static String getClassTableName(
    PersistentClass model,
    Element node,
    String schema,
    String catalog,
    Table denormalizedSuperTable,
    Mappings mappings) {
  Attribute tableNameNode = node.attribute( "table" );
  String logicalTableName;
  String physicalTableName;
  if ( tableNameNode == null ) {
    logicalTableName = StringHelper.unqualify( model.getEntityName() );
    physicalTableName = mappings.getNamingStrategy().classToTableName( model.getEntityName() );
  }
  else {
    logicalTableName = tableNameNode.getValue();
    physicalTableName = mappings.getNamingStrategy().tableName( logicalTableName );
  }
  mappings.addTableBinding( schema, catalog, logicalTableName, physicalTableName, denormalizedSuperTable );
  return physicalTableName;
}
origin: jboss.jboss-embeddable-ejb3/hibernate-all

    column.setTypeIndex( count++ );
    bindColumn( columnElement, column, isNullable );
    String logicalColumnName = mappings.getNamingStrategy().logicalColumnName(
        columnElement.attributeValue( "name" ), propertyPath
    );
    column.setName( mappings.getNamingStrategy().columnName(
      logicalColumnName ) );
    if ( table != null ) {
column.setValue( simpleValue );
bindColumn( node, column, isNullable );
String logicalColumnName = mappings.getNamingStrategy().logicalColumnName(
    columnAttribute.getValue(), propertyPath
);
column.setName( mappings.getNamingStrategy().columnName( logicalColumnName ) );
if ( table != null ) {
column.setValue( simpleValue );
bindColumn( node, column, isNullable );
column.setName( mappings.getNamingStrategy().propertyToColumnName( propertyPath ) );
String logicalName = mappings.getNamingStrategy().logicalColumnName( null, propertyPath );
mappings.addColumnBinding( logicalName, column, table );
org.hibernate.cfgNamingStrategy

Javadoc

A set of rules for determining the physical column and table names given the information in the mapping document. May be used to implement project-scoped naming standards for database objects. #propertyToTableName(String, String) should be replaced by #collectionTableName(String,String,String,String,String)

Most used methods

  • propertyToColumnName
    Return a column name for a property path expression
  • classToTableName
    Return a table name for an entity class
  • tableName
    Alter the table name given in the mapping document
  • columnName
    Alter the column name given in the mapping document
  • collectionTableName
    Return a collection table name ie an association having a join table
  • foreignKeyColumnName
    Return the foreign key column name for the given parameters
  • joinKeyColumnName
    Return the join key column name ie a FK column used in a JOINED strategy or for a secondary table
  • logicalCollectionColumnName
    Returns the logical foreign key column name used to refer to this column in the mapping metadata
  • logicalCollectionTableName
    Returns the logical collection table name used to refer to a table in the mapping metadata
  • logicalColumnName
    Return the logical column name used to refer to a column in the metadata (like index, unique constra
  • propertyToTableName
    Return a table name for a collection
  • propertyToTableName

Popular in Java

  • Updating database using SQL prepared statement
  • getApplicationContext (Context)
  • scheduleAtFixedRate (Timer)
  • getExternalFilesDir (Context)
  • HttpURLConnection (java.net)
    An URLConnection for HTTP (RFC 2616 [http://tools.ietf.org/html/rfc2616]) used to send and receive d
  • Iterator (java.util)
    An iterator over a sequence of objects, such as a collection.If a collection has been changed since
  • NoSuchElementException (java.util)
    Thrown when trying to retrieve an element past the end of an Enumeration or Iterator.
  • JarFile (java.util.jar)
    JarFile is used to read jar entries and their associated data from jar files.
  • Cipher (javax.crypto)
    This class provides access to implementations of cryptographic ciphers for encryption and decryption
  • IOUtils (org.apache.commons.io)
    General IO stream manipulation utilities. This class provides static utility methods for input/outpu
  • CodeWhisperer alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now