Skip to content

Commit 01fe115

Browse files
committed
HHH-6100 unqualify entity name and minor improvement
1 parent b0f2658 commit 01fe115

File tree

3 files changed

+19
-25
lines changed

3 files changed

+19
-25
lines changed

hibernate-core/src/main/java/org/hibernate/cfg/HbmBinder.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ private static void bindRootPersistentClassCommonValues(Element node,
339339
catalog,
340340
getClassTableName( entity, node, schema, catalog, null, mappings ),
341341
getSubselect( node ),
342-
entity.isAbstract() != null && entity.isAbstract().booleanValue()
342+
entity.isAbstract() != null && entity.isAbstract()
343343
);
344344
entity.setTable( table );
345345
bindComment(table, node);
@@ -571,7 +571,7 @@ public static void bindClass(Element node, PersistentClass persistentClass, Mapp
571571
throw new MappingException( "Unable to determine entity name" );
572572
}
573573
persistentClass.setEntityName( entityName );
574-
persistentClass.setJpaEntityName( entityName );
574+
persistentClass.setJpaEntityName( StringHelper.unqualify( entityName ) );
575575

576576
bindPojoRepresentation( node, persistentClass, mappings, inheritedMetas );
577577
bindDom4jRepresentation( node, persistentClass, mappings, inheritedMetas );
@@ -840,7 +840,7 @@ public static void bindUnionSubclass(Element node, UnionSubclass unionSubclass,
840840
schema,
841841
catalog,
842842
getClassTableName(unionSubclass, node, schema, catalog, denormalizedSuperTable, mappings ),
843-
unionSubclass.isAbstract() != null && unionSubclass.isAbstract().booleanValue(),
843+
unionSubclass.isAbstract() != null && unionSubclass.isAbstract(),
844844
getSubselect( node ),
845845
denormalizedSuperTable
846846
);

hibernate-core/src/main/java/org/hibernate/internal/util/StringHelper.java

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ public static String[] split(String seperators, String list, boolean include) {
224224

225225
public static String unqualify(String qualifiedName) {
226226
int loc = qualifiedName.lastIndexOf(".");
227-
return ( loc < 0 ) ? qualifiedName : qualifiedName.substring( qualifiedName.lastIndexOf(".") + 1 );
227+
return ( loc < 0 ) ? qualifiedName : qualifiedName.substring( loc + 1 );
228228
}
229229

230230
public static String qualifier(String qualifiedName) {
@@ -600,12 +600,7 @@ else if ( name.startsWith( "\"" ) && name.endsWith( "\"" ) ) {
600600
* @return The unquoted version.
601601
*/
602602
public static String unquote(String name) {
603-
if ( isQuoted( name ) ) {
604-
return name.substring( 1, name.length() - 1 );
605-
}
606-
else {
607-
return name;
608-
}
603+
return isQuoted( name ) ? name.substring( 1, name.length() - 1 ) : name;
609604
}
610605

611606
/**
@@ -622,9 +617,18 @@ public static String unquote(String name) {
622617
* @return True if quoted, false otherwise
623618
*/
624619
public static boolean isQuoted(String name, Dialect dialect) {
625-
return name != null && name.length() != 0
626-
&& ( name.charAt( 0 ) == '`' && name.charAt( name.length() - 1 ) == '`'
627-
|| name.charAt( 0 ) == dialect.openQuote() && name.charAt( name.length() - 1 ) == dialect.closeQuote() );
620+
return name != null
621+
&&
622+
name.length() != 0
623+
&& (
624+
name.charAt( 0 ) == '`'
625+
&&
626+
name.charAt( name.length() - 1 ) == '`'
627+
||
628+
name.charAt( 0 ) == dialect.openQuote()
629+
&&
630+
name.charAt( name.length() - 1 ) == dialect.closeQuote()
631+
);
628632
}
629633

630634
/**
@@ -636,12 +640,7 @@ public static boolean isQuoted(String name, Dialect dialect) {
636640
* @return The unquoted version.
637641
*/
638642
public static String unquote(String name, Dialect dialect) {
639-
if ( isQuoted( name, dialect ) ) {
640-
return name.substring( 1, name.length() - 1 );
641-
}
642-
else {
643-
return name;
644-
}
643+
return isQuoted( name, dialect ) ? name.substring( 1, name.length() - 1 ) : name;
645644
}
646645

647646
/**

hibernate-core/src/main/java/org/hibernate/sql/Alias.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,7 @@ private String getUnquotedAliasString(String sqlIdentifier, int quoteType) {
8585
//truncate the identifier to the max alias length, less the suffix length
8686
unquoted = unquoted.substring(0, length);
8787
}
88-
if ( suffix == null ) {
89-
return unquoted;
90-
}
91-
else {
92-
return unquoted + suffix;
93-
}
88+
return ( suffix == null ) ? unquoted : unquoted + suffix;
9489
}
9590

9691
public String[] toUnquotedAliasStrings(String[] sqlIdentifiers) {

0 commit comments

Comments
 (0)