mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-16 16:15:06 +00:00
HHH-13856 - Long-awaited TODOs done as an improvement
1. TODO: Remove duplicate method from ConstraintConstaint.java currently has two duplicate methods. 1. getColumnIterator()2. columnIterator() Both the methods return the same value i.e. column.iterator(). One of them needs to be removed in order to reduce and clean the duplication. 2. TODO: Change method name for getXmlFiles in BaseCoreFunctionalTestCaseCurrently, in BaseCoreFunctionalTestCase a method named getXmlFiles()has a TODO placed that suggests the method name to be changed to getOrmXmlFiles(). Since the method has a protected scope, there is a possibility it is being used by other clients. Hence, changing the method name in minor versions might break the code for clients.
This commit is contained in:
parent
86a8106696
commit
e808041477
@ -35,7 +35,7 @@ public String getAlterTableToAddUniqueKeyCommand(UniqueKey uniqueKey, Metadata m
|
|||||||
dialect,
|
dialect,
|
||||||
uniqueKey.getName(),
|
uniqueKey.getName(),
|
||||||
uniqueKey.getTable(),
|
uniqueKey.getTable(),
|
||||||
uniqueKey.columnIterator(),
|
uniqueKey.getColumnIterator(),
|
||||||
uniqueKey.getColumnOrderMap(),
|
uniqueKey.getColumnOrderMap(),
|
||||||
true,
|
true,
|
||||||
metadata
|
metadata
|
||||||
@ -63,7 +63,7 @@ public String getAlterTableToDropUniqueKeyCommand(UniqueKey uniqueKey, Metadata
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean hasNullable(org.hibernate.mapping.UniqueKey uniqueKey) {
|
private boolean hasNullable(org.hibernate.mapping.UniqueKey uniqueKey) {
|
||||||
final Iterator<org.hibernate.mapping.Column> iter = uniqueKey.columnIterator();
|
final Iterator<org.hibernate.mapping.Column> iter = uniqueKey.getColumnIterator();
|
||||||
while ( iter.hasNext() ) {
|
while ( iter.hasNext() ) {
|
||||||
if ( iter.next().isNullable() ) {
|
if ( iter.next().isNullable() ) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -60,7 +60,7 @@ public String getAlterTableToAddUniqueKeyCommand(UniqueKey uniqueKey, Metadata m
|
|||||||
protected String uniqueConstraintSql(UniqueKey uniqueKey) {
|
protected String uniqueConstraintSql(UniqueKey uniqueKey) {
|
||||||
final StringBuilder sb = new StringBuilder();
|
final StringBuilder sb = new StringBuilder();
|
||||||
sb.append( "unique (" );
|
sb.append( "unique (" );
|
||||||
final Iterator<org.hibernate.mapping.Column> columnIterator = uniqueKey.columnIterator();
|
final Iterator<org.hibernate.mapping.Column> columnIterator = uniqueKey.getColumnIterator();
|
||||||
while ( columnIterator.hasNext() ) {
|
while ( columnIterator.hasNext() ) {
|
||||||
final org.hibernate.mapping.Column column = columnIterator.next();
|
final org.hibernate.mapping.Column column = columnIterator.next();
|
||||||
sb.append( column.getQuotedName( dialect ) );
|
sb.append( column.getQuotedName( dialect ) );
|
||||||
|
@ -151,12 +151,8 @@ public int getColumnSpan() {
|
|||||||
public Column getColumn(int i) {
|
public Column getColumn(int i) {
|
||||||
return columns.get( i );
|
return columns.get( i );
|
||||||
}
|
}
|
||||||
//todo duplicated method, remove one
|
|
||||||
public Iterator<Column> getColumnIterator() {
|
|
||||||
return columns.iterator();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Iterator<Column> columnIterator() {
|
public Iterator<Column> getColumnIterator() {
|
||||||
return columns.iterator();
|
return columns.iterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -373,7 +373,7 @@ else if ( uniqueKeys.size() == 1 ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean isSameAsPrimaryKeyColumns(UniqueKey uniqueKey) {
|
private boolean isSameAsPrimaryKeyColumns(UniqueKey uniqueKey) {
|
||||||
if ( primaryKey == null || ! primaryKey.columnIterator().hasNext() ) {
|
if ( primaryKey == null || ! primaryKey.getColumnIterator().hasNext() ) {
|
||||||
// happens for many-to-many tables
|
// happens for many-to-many tables
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -234,7 +234,7 @@ protected String[] getAnnotatedPackages() {
|
|||||||
|
|
||||||
// Simply having this orm.xml file in the classpath reproduces HHH-4261.
|
// Simply having this orm.xml file in the classpath reproduces HHH-4261.
|
||||||
@Override
|
@Override
|
||||||
protected String[] getXmlFiles() {
|
protected String[] getOrmXmlFiles() {
|
||||||
return new String[] { "org/hibernate/test/annotations/any/orm.xml" };
|
return new String[] { "org/hibernate/test/annotations/any/orm.xml" };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ public void testProxiedBridgeMethod() throws Exception {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String[] getXmlFiles() {
|
protected String[] getOrmXmlFiles() {
|
||||||
return new String[] {
|
return new String[] {
|
||||||
"org/hibernate/test/annotations/bytecode/Hammer.hbm.xml"
|
"org/hibernate/test/annotations/bytecode/Hammer.hbm.xml"
|
||||||
};
|
};
|
||||||
|
@ -44,7 +44,7 @@ protected Class[] getAnnotatedClasses() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String[] getXmlFiles() {
|
protected String[] getOrmXmlFiles() {
|
||||||
return new String[] {
|
return new String[] {
|
||||||
"org/hibernate/test/annotations/idclass/xml/HabitatSpeciesLink.xml"
|
"org/hibernate/test/annotations/idclass/xml/HabitatSpeciesLink.xml"
|
||||||
};
|
};
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
*/
|
*/
|
||||||
public class LoaderTest extends BaseCoreFunctionalTestCase {
|
public class LoaderTest extends BaseCoreFunctionalTestCase {
|
||||||
@Override
|
@Override
|
||||||
protected String[] getXmlFiles() {
|
protected String[] getOrmXmlFiles() {
|
||||||
return new String[] {
|
return new String[] {
|
||||||
"org/hibernate/test/annotations/loader/Loader.hbm.xml"
|
"org/hibernate/test/annotations/loader/Loader.hbm.xml"
|
||||||
};
|
};
|
||||||
|
@ -166,7 +166,7 @@ protected Class[] getAnnotatedClasses() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String[] getXmlFiles() {
|
protected String[] getOrmXmlFiles() {
|
||||||
return new String[] { "org/hibernate/test/annotations/onetoone/orm.xml" };
|
return new String[] { "org/hibernate/test/annotations/onetoone/orm.xml" };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -649,7 +649,7 @@ protected String[] getAnnotatedPackages() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String[] getXmlFiles() {
|
protected String[] getOrmXmlFiles() {
|
||||||
return new String[] {
|
return new String[] {
|
||||||
"org/hibernate/test/annotations/query/orm.xml"
|
"org/hibernate/test/annotations/query/orm.xml"
|
||||||
};
|
};
|
||||||
|
@ -24,7 +24,7 @@ protected Class[] getAnnotatedClasses() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String[] getXmlFiles() {
|
protected String[] getOrmXmlFiles() {
|
||||||
return new String[] { "org/hibernate/test/annotations/reflection/element-collection-converter-orm.xml" };
|
return new String[] { "org/hibernate/test/annotations/reflection/element-collection-converter-orm.xml" };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,7 +130,7 @@ protected Class[] getAnnotatedClasses() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String[] getXmlFiles() {
|
protected String[] getOrmXmlFiles() {
|
||||||
return new String[] {
|
return new String[] {
|
||||||
"org/hibernate/test/annotations/xml/ejb3/orm.xml",
|
"org/hibernate/test/annotations/xml/ejb3/orm.xml",
|
||||||
"org/hibernate/test/annotations/xml/ejb3/orm2.xml",
|
"org/hibernate/test/annotations/xml/ejb3/orm2.xml",
|
||||||
|
@ -54,7 +54,7 @@ public void testOrm1Support() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String[] getXmlFiles() {
|
protected String[] getOrmXmlFiles() {
|
||||||
return new String[] { "org/hibernate/test/annotations/xml/ejb3/orm2.xml" };
|
return new String[] { "org/hibernate/test/annotations/xml/ejb3/orm2.xml" };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,7 @@ protected Class[] getAnnotatedClasses() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String[] getXmlFiles() {
|
protected String[] getOrmXmlFiles() {
|
||||||
return new String[]{
|
return new String[]{
|
||||||
"org/hibernate/test/annotations/xml/hbm/Government.hbm.xml",
|
"org/hibernate/test/annotations/xml/hbm/Government.hbm.xml",
|
||||||
"org/hibernate/test/annotations/xml/hbm/CloudType.hbm.xml",
|
"org/hibernate/test/annotations/xml/hbm/CloudType.hbm.xml",
|
||||||
|
@ -42,7 +42,7 @@ protected Class[] getAnnotatedClasses() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String[] getXmlFiles() {
|
protected String[] getOrmXmlFiles() {
|
||||||
return new String[] {
|
return new String[] {
|
||||||
"org/hibernate/test/annotations/xml/hbm/A.hbm.xml",
|
"org/hibernate/test/annotations/xml/hbm/A.hbm.xml",
|
||||||
"org/hibernate/test/annotations/xml/hbm/B.hbm.xml",
|
"org/hibernate/test/annotations/xml/hbm/B.hbm.xml",
|
||||||
|
@ -633,7 +633,7 @@ public void generateFirstPass(
|
|||||||
|
|
||||||
// Adding the "key" element with all id columns...
|
// Adding the "key" element with all id columns...
|
||||||
final Element keyMapping = mappingData.getFirst().addElement( "key" );
|
final Element keyMapping = mappingData.getFirst().addElement( "key" );
|
||||||
MetadataTools.addColumns( keyMapping, pc.getTable().getPrimaryKey().columnIterator(), metadata );
|
MetadataTools.addColumns( keyMapping, pc.getTable().getPrimaryKey().getColumnIterator(), metadata );
|
||||||
|
|
||||||
// ... and the revision number column, read from the revision info relation mapping.
|
// ... and the revision number column, read from the revision info relation mapping.
|
||||||
keyMapping.add( (Element) cloneAndSetupRevisionInfoRelationMapping().element( "column" ).clone() );
|
keyMapping.add( (Element) cloneAndSetupRevisionInfoRelationMapping().element( "column" ).clone() );
|
||||||
|
@ -204,7 +204,7 @@ protected void addMappings(Configuration configuration) {
|
|||||||
configuration.addPackage( annotatedPackage );
|
configuration.addPackage( annotatedPackage );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
String[] xmlFiles = getXmlFiles();
|
String[] xmlFiles = getOrmXmlFiles();
|
||||||
if ( xmlFiles != null ) {
|
if ( xmlFiles != null ) {
|
||||||
for ( String xmlFile : xmlFiles ) {
|
for ( String xmlFile : xmlFiles ) {
|
||||||
try ( InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream( xmlFile ) ) {
|
try ( InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream( xmlFile ) ) {
|
||||||
@ -237,8 +237,7 @@ protected String[] getAnnotatedPackages() {
|
|||||||
return NO_MAPPINGS;
|
return NO_MAPPINGS;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String[] getXmlFiles() {
|
protected String[] getOrmXmlFiles() {
|
||||||
// todo : rename to getOrmXmlFiles()
|
|
||||||
return NO_MAPPINGS;
|
return NO_MAPPINGS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user