@Override public String toMetaDataObjectName(Identifier identifier) { return identifier.getText(); } }
public IndexInformationImpl build() { if ( columnList.isEmpty() ) { throw new SchemaManagementException( "Attempt to resolve JDBC metadata failed to find columns for index [" + indexIdentifier.getText() + "]" ); } return new IndexInformationImpl( indexIdentifier, Collections.unmodifiableList( columnList ) ); } }
@Override public ForeignKeyInformationImpl build() { if ( columnMappingList.isEmpty() ) { throw new SchemaManagementException( "Attempt to resolve foreign key metadata from JDBC metadata failed to find " + "column mappings for foreign key named [" + fkIdentifier.getText() + "]" ); } return new ForeignKeyInformationImpl( fkIdentifier, columnMappingList ); } }
public static Identifier quote(Identifier identifier) { return identifier.isQuoted() ? identifier : Identifier.toIdentifier( identifier.getText(), true ); }
public void setQuoted(boolean quoted) { if ( quoted == name.isQuoted() ) { return; } this.name = new Identifier( name.getText(), quoted ); }
@Override public Identifier normalizeQuoting(Identifier identifier) { Identifier normalizedIdentifier = this.helper.normalizeQuoting( identifier ); if ( normalizedIdentifier == null ) { return null; } // need to quote names containing special characters like ':' if ( !normalizedIdentifier.isQuoted() && !normalizedIdentifier.getText().matches( "\\w+" ) ) { normalizedIdentifier = Identifier.quote( normalizedIdentifier ); } return normalizedIdentifier; }
@Override public Identifier toPhysicalTableName(Identifier name, JdbcEnvironment jdbcEnvironment) { return Identifier.toIdentifier( "TAB_" + name.getText() ); } }
@Override public Identifier toPhysicalColumnName( Identifier name, JdbcEnvironment context) { return new Identifier( name.getText().toUpperCase(), name.isQuoted() ); } } )
@Override public boolean includeNamespace(Namespace namespace) { // exclude schema "the_schema_2" Identifier identifier = namespace.getName().getSchema(); if ( identifier != null ) { return !"the_schema_2".equals( identifier.getText() ); } return true; }
@Override public boolean includeNamespace(Namespace namespace) { // exclude schema "the_catalog_2" Identifier identifier = namespace.getName().getCatalog(); return identifier == null || !"the_catalog_2".equals( identifier.getText() ); }
@Override public Identifier toPhysicalSequenceName(Identifier name, JdbcEnvironment jdbcEnvironment) { final LinkedList<String> parts = splitAndReplace( name.getText() ); // Acme Corp says all sequences should end with _seq if ( !"seq".equalsIgnoreCase( parts.getLast() ) ) { parts.add( "seq" ); } return jdbcEnvironment.getIdentifierHelper().toIdentifier( join( parts ), name.isQuoted() ); }
@Override public Identifier toPhysicalTableName(Identifier name, JdbcEnvironment jdbcEnvironment) { return Identifier.toIdentifier(makeCleanIdentifier("tbl_" + name.getText()), name.isQuoted()); }
@Override public Identifier determineCollectionTableName(ImplicitCollectionTableNameSource source) { Identifier identifier = toIdentifier( source.getOwningPhysicalTableName().getText() + "_" + transformAttributePath( source.getOwningAttributePath() ), source.getBuildingContext() ); if ( source.getOwningPhysicalTableName().isQuoted() ) { identifier = Identifier.quote( identifier ); } return identifier; }
@Test public void testTableNaming() { { Identifier in = Identifier.toIdentifier( "accountNumber" ); Identifier out = strategy.toPhysicalTableName( in, serviceRegistry.getService( JdbcEnvironment.class ) ); assertThat( out.getText(), equalTo( "acct_num" ) ); } } }
@Override public Identifier toPhysicalColumnName(Identifier name, JdbcEnvironment jdbcEnvironment) { final List<String> parts = splitAndReplace( name.getText() ); return jdbcEnvironment.getIdentifierHelper().toIdentifier( join( parts ), name.isQuoted() ); }
@Override public Identifier determineCollectionTableName(ImplicitCollectionTableNameSource source) { // This impl uses the owner entity table name instead of the JPA entity name when // generating the implicit name. final String name = source.getOwningPhysicalTableName().getText() + '_' + transformAttributePath( source.getOwningAttributePath() ); return toIdentifier( name, source.getBuildingContext() ); }
@Override public Identifier toPhysicalTableName(Identifier name, JdbcEnvironment jdbcEnvironment) { final List<String> parts = splitAndReplace( name.getText() ); return jdbcEnvironment.getIdentifierHelper().toIdentifier( join( parts ), name.isQuoted() ); }