本文整理了Java中org.hibernate.boot.model.naming.Identifier.isQuoted()
方法的一些代码示例,展示了Identifier.isQuoted()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Identifier.isQuoted()
方法的具体详情如下:
包路径:org.hibernate.boot.model.naming.Identifier
类名称:Identifier
方法名:isQuoted
[英]Is this a quoted identifier>
[中]这是一个带引号的标识符>
代码示例来源:origin: hibernate/hibernate-orm
public boolean isCatalogQuoted() {
return catalog != null && catalog.isQuoted();
}
代码示例来源:origin: hibernate/hibernate-orm
public boolean isQuoted() {
return name.isQuoted();
}
代码示例来源:origin: hibernate/hibernate-orm
public boolean isSchemaQuoted() {
return schema != null && schema.isQuoted();
}
代码示例来源:origin: hibernate/hibernate-orm
private void bindLogicalToPhysical(Identifier logicalName, String physicalName) throws DuplicateMappingException {
final String existingPhysicalNameMapping = logicalToPhysical.put( logicalName, physicalName );
if ( existingPhysicalNameMapping != null ) {
final boolean areSame = logicalName.isQuoted()
? physicalName.equals( existingPhysicalNameMapping )
: physicalName.equalsIgnoreCase( existingPhysicalNameMapping );
if ( !areSame ) {
throw new DuplicateMappingException(
String.format(
Locale.ENGLISH,
"Table [%s] contains logical column name [%s] referring to multiple physical " +
"column names: [%s], [%s]",
tableName,
logicalName,
existingPhysicalNameMapping,
physicalName
),
DuplicateMappingException.Type.COLUMN_BINDING,
tableName + "." + logicalName
);
}
}
}
代码示例来源:origin: org.springframework.boot/spring-boot
private Identifier apply(Identifier name, JdbcEnvironment jdbcEnvironment) {
if (name == null) {
return null;
}
StringBuilder builder = new StringBuilder(name.getText().replace('.', '_'));
for (int i = 1; i
builder.charAt(i + 1))) {
builder.insert(i++, '_');
}
}
return getIdentifier(builder.toString(), name.isQuoted(), jdbcEnvironment);
}
代码示例来源:origin: hibernate/hibernate-orm
public static Identifier quote(Identifier identifier) {
return identifier.isQuoted()
? identifier
: Identifier.toIdentifier( identifier.getText(), true );
}
代码示例来源:origin: hibernate/hibernate-orm
public void setQuoted(boolean quoted) {
if ( quoted == name.isQuoted() ) {
return;
}
this.name = new Identifier( name.getText(), quoted );
}
代码示例来源:origin: hibernate/hibernate-orm
@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;
}
代码示例来源:origin: hibernate/hibernate-orm
private String[] quoteTypeIfNecessary(org.hibernate.mapping.Table table, String[] strings, String prefix) {
if ( table.getNameIdentifier() == null || table.getNameIdentifier().isQuoted()
|| !"type".equals( table.getNameIdentifier().getText().toLowerCase() ) ) {
return strings;
}
Pattern createTableTypePattern = Pattern.compile( "(" + prefix + "\\s+)(" + table.getNameIdentifier().getText() + ")(.+)" );
Pattern commentOnTableTypePattern= Pattern.compile( "(comment\\s+on\\s+table\\s+)(" + table.getNameIdentifier().getText() + ")(.+)" );
for ( int i = 0; i
Matcher commentOnTableTypeMatcher= commentOnTableTypePattern.matcher( strings[i] );
if ( createTableTypeMatcher.matches() ) {
strings[i] = createTableTypeMatcher.group( 1 ) + "\"TYPE\"" + createTableTypeMatcher.group( 3 );
}
if ( commentOnTableTypeMatcher.matches() ) {
strings[i] = commentOnTableTypeMatcher.group( 1 ) + "\"TYPE\"" + commentOnTableTypeMatcher.group( 3 );
}
}
return strings;
}
};
代码示例来源:origin: hibernate/hibernate-orm
/**
* Constructs an identifier instance.
*
* @param text The identifier text.
* @param quoted Is this a quoted identifier?
*/
public Identifier(String text, boolean quoted) {
if ( StringHelper.isEmpty( text ) ) {
throw new IllegalIdentifierException( "Identifier text cannot be null" );
}
if ( isQuoted( text ) ) {
throw new IllegalIdentifierException( "Identifier text should not contain quote markers (` or \")" );
}
this.text = text;
this.isQuoted = quoted;
}
代码示例来源:origin: hibernate/hibernate-orm
@Override
public Identifier toPhysicalColumnName(
Identifier name, JdbcEnvironment context) {
return new Identifier( name.getText().toUpperCase(), name.isQuoted() );
}
} )
代码示例来源:origin: hibernate/hibernate-orm
@Override
public Identifier toPhysicalSequenceName(Identifier name, JdbcEnvironment jdbcEnvironment) {
final LinkedList
// 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()
);
}
代码示例来源:origin: hibernate/hibernate-orm
@Override
public Identifier toPhysicalColumnName(Identifier name, JdbcEnvironment jdbcEnvironment) {
if ( name.getText().equals("DTYPE") ) {
return name;
}
return Identifier.toIdentifier(makeCleanIdentifier("c_" + name.getText()), name.isQuoted());
}
代码示例来源:origin: hibernate/hibernate-orm
@Override
public Identifier toPhysicalTableName(Identifier name, JdbcEnvironment jdbcEnvironment) {
return Identifier.toIdentifier(makeCleanIdentifier("tbl_" + name.getText()), name.isQuoted());
}
代码示例来源:origin: hibernate/hibernate-orm
@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;
}
代码示例来源:origin: hibernate/hibernate-orm
@Override
public Identifier toPhysicalTableName(Identifier name, JdbcEnvironment jdbcEnvironment) {
final List
return jdbcEnvironment.getIdentifierHelper().toIdentifier(
join( parts ),
name.isQuoted()
);
}
代码示例来源:origin: hibernate/hibernate-orm
@Override
public Identifier toPhysicalColumnName(Identifier name, JdbcEnvironment jdbcEnvironment) {
final List
return jdbcEnvironment.getIdentifierHelper().toIdentifier(
join( parts ),
name.isQuoted()
);
}
代码示例来源:origin: hibernate/hibernate-orm
@Override
public Identifier normalizeQuoting(Identifier identifier) {
log.tracef( "Normalizing identifier quoting [%s]", identifier );
if ( identifier == null ) {
return null;
}
if ( identifier.isQuoted() ) {
return identifier;
}
if ( globallyQuoteIdentifiers ) {
log.tracef( "Forcing identifier [%s] to quoted for global quoting", identifier );
return Identifier.toIdentifier( identifier.getText(), true );
}
if ( autoQuoteKeywords && isReservedWord( identifier.getText() ) ) {
log.tracef( "Forcing identifier [%s] to quoted as recognized reserved word", identifier );
return Identifier.toIdentifier( identifier.getText(), true );
}
return identifier;
}
代码示例来源:origin: hibernate/hibernate-orm
@Test
public void testAutoQuotingDisabled() {
ServiceRegistry sr = ServiceRegistryTestingImpl.forUnitTesting(
Collections.singletonMap(
AvailableSettings.KEYWORD_AUTO_QUOTING_ENABLED,
// true is the default, but to be sure...
true
)
);
Identifier identifier = sr.getService( JdbcEnvironment.class ).getIdentifierHelper().toIdentifier( "select" );
assertTrue( identifier.isQuoted() );
StandardServiceRegistryBuilder.destroy( sr );
sr = ServiceRegistryTestingImpl.forUnitTesting(
Collections.singletonMap(
AvailableSettings.KEYWORD_AUTO_QUOTING_ENABLED,
false
)
);
identifier = sr.getService( JdbcEnvironment.class ).getIdentifierHelper().toIdentifier( "select" );
assertFalse( identifier.isQuoted() );
StandardServiceRegistryBuilder.destroy( sr );
}
}
代码示例来源:origin: hibernate/hibernate-orm
@Test
@TestForIssue( jiraKey = "HHH_9768" )
public void testAnsiSqlKeyword() {
// END is ANSI SQL keyword
JdbcEnvironment jdbcEnvirOnment= serviceRegistry.getService( JdbcEnvironment.class );
assertTrue( jdbcEnvironment.getIdentifierHelper().isReservedWord( "end" ) );
assertTrue( jdbcEnvironment.getIdentifierHelper().isReservedWord( "END" ) );
Identifier identifier = jdbcEnvironment.getIdentifierHelper().toIdentifier( "end" );
assertTrue( identifier.isQuoted() );
}
}