HHH-7841 - Redesign Loader

This commit is contained in:
Steve Ebersole 2013-04-12 09:04:12 -05:00
parent cbbadea538
commit 1d9f6201a0
2 changed files with 68 additions and 8 deletions

View File

@ -0,0 +1,42 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2013, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.envers.configuration.internal.metadata;
import org.hibernate.HibernateException;
/**
* Exception indicating that a formula mapping was encountered where it is not currently supported
*
* @author Steve Ebersole
*/
public class FormulaNotSupportedException extends HibernateException {
private static final String MSG = "Formula mappings (aside from @DiscriminatorValue) are currently not supported";
/**
* Constructs a FormulaNotSupportedException using a standard message
*/
public FormulaNotSupportedException() {
super( MSG );
}
}

View File

@ -32,6 +32,7 @@ import org.dom4j.Element;
import org.hibernate.envers.internal.tools.StringTools;
import org.hibernate.mapping.Column;
import org.hibernate.mapping.Formula;
import org.hibernate.mapping.Selectable;
/**
* @author Adam Warski (adam at warski dot org)
@ -221,9 +222,13 @@ public class MetadataTools {
return join_mapping;
}
public static void addColumns(Element any_mapping, Iterator<Column> columns) {
while (columns.hasNext()) {
addColumn(any_mapping, columns.next());
public static void addColumns(Element any_mapping, Iterator selectables) {
while ( selectables.hasNext() ) {
final Selectable selectable = (Selectable) selectables.next();
if ( selectable.isFormula() ) {
throw new FormulaNotSupportedException();
}
addColumn( any_mapping, (Column) selectable );
}
}
@ -310,13 +315,26 @@ public class MetadataTools {
/**
* An iterator over column names.
*/
public static abstract class ColumnNameIterator implements Iterator<String> { }
public static abstract class ColumnNameIterator implements Iterator<String> {
}
public static ColumnNameIterator getColumnNameIterator(final Iterator<Column> columnIterator) {
public static ColumnNameIterator getColumnNameIterator(final Iterator<Selectable> selectableIterator) {
return new ColumnNameIterator() {
public boolean hasNext() { return columnIterator.hasNext(); }
public String next() { return columnIterator.next().getName(); }
public void remove() { columnIterator.remove(); }
public boolean hasNext() {
return selectableIterator.hasNext();
}
public String next() {
final Selectable next = selectableIterator.next();
if ( next.isFormula() ) {
throw new FormulaNotSupportedException();
}
return ( (Column) next ).getName();
}
public void remove() {
selectableIterator.remove();
}
};
}