HHH-6216 Formatting and removing of obsolete imports and class
This commit is contained in:
parent
bfa4734521
commit
ae8a29bdb2
|
@ -23,8 +23,6 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.metamodel.relational;
|
package org.hibernate.metamodel.relational;
|
||||||
|
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
|
||||||
|
|
||||||
import org.hibernate.dialect.Dialect;
|
import org.hibernate.dialect.Dialect;
|
||||||
import org.hibernate.internal.util.StringHelper;
|
import org.hibernate.internal.util.StringHelper;
|
||||||
|
|
||||||
|
@ -41,7 +39,7 @@ public class UniqueKey extends AbstractConstraint implements Constraint {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getExportIdentifier() {
|
public String getExportIdentifier() {
|
||||||
StringBuilder sb = new StringBuilder( getTable().getLoggableValueQualifier());
|
StringBuilder sb = new StringBuilder( getTable().getLoggableValueQualifier() );
|
||||||
sb.append( ".UK" );
|
sb.append( ".UK" );
|
||||||
for ( Column column : getColumns() ) {
|
for ( Column column : getColumns() ) {
|
||||||
sb.append( '_' ).append( column.getColumnName().getName() );
|
sb.append( '_' ).append( column.getColumnName().getName() );
|
||||||
|
@ -71,15 +69,15 @@ public class UniqueKey extends AbstractConstraint implements Constraint {
|
||||||
first = false;
|
first = false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
buf.append(", ");
|
buf.append( ", " );
|
||||||
}
|
}
|
||||||
if ( ! hadNullableColumn && column.isNullable() ) {
|
if ( !hadNullableColumn && column.isNullable() ) {
|
||||||
hadNullableColumn = true;
|
hadNullableColumn = true;
|
||||||
}
|
}
|
||||||
buf.append( column.getColumnName().encloseInQuotesIfQuoted( dialect ) );
|
buf.append( column.getColumnName().encloseInQuotesIfQuoted( dialect ) );
|
||||||
}
|
}
|
||||||
//do not add unique constraint on DB not supporting unique and nullable columns
|
//do not add unique constraint on DB not supporting unique and nullable columns
|
||||||
return ! hadNullableColumn || dialect.supportsNotNullUnique() ?
|
return !hadNullableColumn || dialect.supportsNotNullUnique() ?
|
||||||
buf.append( ')' ).toString() :
|
buf.append( ')' ).toString() :
|
||||||
null;
|
null;
|
||||||
}
|
}
|
||||||
|
@ -95,14 +93,14 @@ public class UniqueKey extends AbstractConstraint implements Constraint {
|
||||||
first = false;
|
first = false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
buf.append(", ");
|
buf.append( ", " );
|
||||||
}
|
}
|
||||||
if ( ! nullable && column.isNullable() ) {
|
if ( !nullable && column.isNullable() ) {
|
||||||
nullable = true;
|
nullable = true;
|
||||||
}
|
}
|
||||||
buf.append( column.getColumnName().encloseInQuotesIfQuoted( dialect ) );
|
buf.append( column.getColumnName().encloseInQuotesIfQuoted( dialect ) );
|
||||||
}
|
}
|
||||||
return ! nullable || dialect.supportsNotNullUnique() ?
|
return !nullable || dialect.supportsNotNullUnique() ?
|
||||||
StringHelper.replace( buf.append( ')' ).toString(), "primary key", "unique" ) :
|
StringHelper.replace( buf.append( ')' ).toString(), "primary key", "unique" ) :
|
||||||
//TODO: improve this hack!
|
//TODO: improve this hack!
|
||||||
null;
|
null;
|
||||||
|
|
|
@ -1,133 +0,0 @@
|
||||||
/*
|
|
||||||
* Hibernate, Relational Persistence for Idiomatic Java
|
|
||||||
*
|
|
||||||
* Copyright (c) 2011, 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.metamodel.relational.state;
|
|
||||||
|
|
||||||
import org.hibernate.MappingException;
|
|
||||||
import org.hibernate.internal.util.StringHelper;
|
|
||||||
import org.hibernate.metamodel.relational.Column;
|
|
||||||
import org.hibernate.metamodel.relational.DerivedValue;
|
|
||||||
import org.hibernate.metamodel.relational.SimpleValue;
|
|
||||||
import org.hibernate.metamodel.relational.TableSpecification;
|
|
||||||
import org.hibernate.metamodel.relational.Tuple;
|
|
||||||
import org.hibernate.metamodel.relational.Value;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Gail Badner
|
|
||||||
*/
|
|
||||||
public class ValueCreator {
|
|
||||||
|
|
||||||
public static Column createColumn(
|
|
||||||
TableSpecification table,
|
|
||||||
String attributeName,
|
|
||||||
ColumnRelationalState state,
|
|
||||||
boolean forceNonNullable,
|
|
||||||
boolean forceUnique) {
|
|
||||||
final String explicitName = state.getExplicitColumnName();
|
|
||||||
final String logicalColumnName = state.getNamingStrategy().logicalColumnName( explicitName, attributeName );
|
|
||||||
String columnName =
|
|
||||||
explicitName == null ?
|
|
||||||
state.getNamingStrategy().propertyToColumnName( attributeName ) :
|
|
||||||
state.getNamingStrategy().columnName( explicitName );
|
|
||||||
// todo : find out the purpose of these logical bindings
|
|
||||||
// mappings.addColumnBinding( logicalColumnName, column, table );
|
|
||||||
|
|
||||||
if ( columnName == null ) {
|
|
||||||
throw new IllegalArgumentException( "columnName must be non-null." );
|
|
||||||
}
|
|
||||||
if ( state.isGloballyQuotedIdentifiers() ) {
|
|
||||||
columnName = StringHelper.quote( columnName );
|
|
||||||
}
|
|
||||||
Column value = table.locateOrCreateColumn( columnName );
|
|
||||||
value.initialize( state, forceNonNullable, forceUnique );
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static DerivedValue createDerivedValue(
|
|
||||||
TableSpecification table,
|
|
||||||
DerivedValueRelationalState state) {
|
|
||||||
return table.locateOrCreateDerivedValue( state.getFormula() );
|
|
||||||
}
|
|
||||||
|
|
||||||
public static SimpleValue createSimpleValue(
|
|
||||||
TableSpecification table,
|
|
||||||
String attributeName,
|
|
||||||
SimpleValueRelationalState state,
|
|
||||||
boolean forceNonNullable,
|
|
||||||
boolean forceUnique) {
|
|
||||||
if ( state instanceof ColumnRelationalState ) {
|
|
||||||
ColumnRelationalState columnRelationalState = ColumnRelationalState.class.cast( state );
|
|
||||||
return createColumn( table, attributeName, columnRelationalState, forceNonNullable, forceUnique );
|
|
||||||
}
|
|
||||||
else if ( state instanceof DerivedValueRelationalState ) {
|
|
||||||
return createDerivedValue( table, DerivedValueRelationalState.class.cast( state ) );
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
throw new MappingException( "unknown relational state:" + state.getClass().getName() );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Tuple createTuple(
|
|
||||||
TableSpecification table,
|
|
||||||
String attributeName,
|
|
||||||
TupleRelationalState state,
|
|
||||||
boolean forceNonNullable,
|
|
||||||
boolean forceUnique) {
|
|
||||||
Tuple tuple = table.createTuple( "[" + attributeName + "]" );
|
|
||||||
for ( SimpleValueRelationalState valueState : state.getRelationalStates() ) {
|
|
||||||
tuple.addValue( createSimpleValue( table, attributeName, valueState, forceNonNullable, forceUnique ) );
|
|
||||||
}
|
|
||||||
return tuple;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Value createValue(
|
|
||||||
TableSpecification table,
|
|
||||||
String attributeName,
|
|
||||||
ValueRelationalState state,
|
|
||||||
boolean forceNonNullable,
|
|
||||||
boolean forceUnique) {
|
|
||||||
Value value = null;
|
|
||||||
if ( SimpleValueRelationalState.class.isInstance( state ) ) {
|
|
||||||
value = createSimpleValue(
|
|
||||||
table,
|
|
||||||
attributeName,
|
|
||||||
SimpleValueRelationalState.class.cast( state ),
|
|
||||||
forceNonNullable,
|
|
||||||
forceUnique
|
|
||||||
);
|
|
||||||
}
|
|
||||||
else if ( TupleRelationalState.class.isInstance( state ) ) {
|
|
||||||
value = createTuple(
|
|
||||||
table,
|
|
||||||
attributeName,
|
|
||||||
TupleRelationalState.class.cast( state ),
|
|
||||||
forceNonNullable,
|
|
||||||
forceUnique
|
|
||||||
);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
throw new MappingException( "Unexpected type of RelationalState" + state.getClass().getName() );
|
|
||||||
}
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -28,7 +28,7 @@ import org.jboss.jandex.DotName;
|
||||||
import org.hibernate.metamodel.source.annotations.JPADotNames;
|
import org.hibernate.metamodel.source.annotations.JPADotNames;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An enum defining the type of mapped attribute.
|
* An enum defining the type of a mapped attribute.
|
||||||
*
|
*
|
||||||
* @author Hardy Ferentschik
|
* @author Hardy Ferentschik
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -41,12 +41,11 @@ import org.hibernate.metamodel.source.annotations.JPADotNames;
|
||||||
import org.hibernate.metamodel.source.annotations.JandexHelper;
|
import org.hibernate.metamodel.source.annotations.JandexHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represent a mapped attribute (explicitly or implicitly mapped). Also used for synthetic attributes like a
|
* Represent a mapped attribute (explicitly or implicitly mapped).
|
||||||
* discriminator column.
|
|
||||||
*
|
*
|
||||||
* @author Hardy Ferentschik
|
* @author Hardy Ferentschik
|
||||||
*/
|
*/
|
||||||
public class SimpleAttribute extends MappedAttribute {
|
public class BasicAttribute extends MappedAttribute {
|
||||||
/**
|
/**
|
||||||
* Is this property an id property (or part thereof).
|
* Is this property an id property (or part thereof).
|
||||||
*/
|
*/
|
||||||
|
@ -89,11 +88,11 @@ public class SimpleAttribute extends MappedAttribute {
|
||||||
private final String customReadFragment;
|
private final String customReadFragment;
|
||||||
private final String checkCondition;
|
private final String checkCondition;
|
||||||
|
|
||||||
public static SimpleAttribute createSimpleAttribute(String name, Class<?> attributeType, Map<DotName, List<AnnotationInstance>> annotations, String accessType) {
|
public static BasicAttribute createSimpleAttribute(String name, Class<?> attributeType, Map<DotName, List<AnnotationInstance>> annotations, String accessType) {
|
||||||
return new SimpleAttribute( name, attributeType, accessType, annotations );
|
return new BasicAttribute( name, attributeType, accessType, annotations );
|
||||||
}
|
}
|
||||||
|
|
||||||
SimpleAttribute(String name, Class<?> attributeType, String accessType, Map<DotName, List<AnnotationInstance>> annotations) {
|
BasicAttribute(String name, Class<?> attributeType, String accessType, Map<DotName, List<AnnotationInstance>> annotations) {
|
||||||
super( name, attributeType, accessType, annotations );
|
super( name, attributeType, accessType, annotations );
|
||||||
|
|
||||||
AnnotationInstance idAnnotation = JandexHelper.getSingleAnnotation( annotations, JPADotNames.ID );
|
AnnotationInstance idAnnotation = JandexHelper.getSingleAnnotation( annotations, JPADotNames.ID );
|
|
@ -0,0 +1,62 @@
|
||||||
|
/*
|
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
|
*
|
||||||
|
* Copyright (c) 2011, 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.metamodel.source.binder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contract describing source of table information
|
||||||
|
*
|
||||||
|
* @author Steve Ebersole
|
||||||
|
*/
|
||||||
|
public interface ConstraintSource {
|
||||||
|
/**
|
||||||
|
* Obtain the supplied schema name
|
||||||
|
*
|
||||||
|
* @return The schema name. If {@code null}, the binder will apply the default.
|
||||||
|
*/
|
||||||
|
public String getExplicitSchemaName();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obtain the supplied catalog name
|
||||||
|
*
|
||||||
|
* @return The catalog name. If {@code null}, the binder will apply the default.
|
||||||
|
*/
|
||||||
|
public String getExplicitCatalogName();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obtain the supplied table name.
|
||||||
|
*
|
||||||
|
* @return The table name.
|
||||||
|
*/
|
||||||
|
public String getExplicitTableName();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obtain the logical name of the table. This value is used to uniquely reference the table when binding
|
||||||
|
* values to the binding model.
|
||||||
|
*
|
||||||
|
* @return The logical name. Can be {@code null} in the case of the "primary table".
|
||||||
|
*
|
||||||
|
* @see org.hibernate.metamodel.source.binder.RelationalValueSource#getContainingTableName()
|
||||||
|
*/
|
||||||
|
public String getLogicalName();
|
||||||
|
}
|
|
@ -28,6 +28,6 @@ package org.hibernate.metamodel.source.binder;
|
||||||
*/
|
*/
|
||||||
public interface PluralAttributeSource extends AttributeSource {
|
public interface PluralAttributeSource extends AttributeSource {
|
||||||
public PluralAttributeNature getPluralAttributeNature();
|
public PluralAttributeNature getPluralAttributeNature();
|
||||||
public PluralAttributeElementNature getPluralAttributeElementNature();
|
|
||||||
|
|
||||||
|
public PluralAttributeElementNature getPluralAttributeElementNature();
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,15 +27,12 @@ package org.hibernate.metamodel.source.binder;
|
||||||
* Unifying interface for {@link ColumnSource} and {@link DerivedValueSource}.
|
* Unifying interface for {@link ColumnSource} and {@link DerivedValueSource}.
|
||||||
*
|
*
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*
|
|
||||||
* @see ColumnSource
|
* @see ColumnSource
|
||||||
* @see DerivedValueSource
|
* @see DerivedValueSource
|
||||||
*/
|
*/
|
||||||
public interface RelationalValueSource {
|
public interface RelationalValueSource {
|
||||||
/**
|
/**
|
||||||
* Obtain the name of the table that contains this value.
|
* @return returns the name of the table that contains this value.
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public String getContainingTableName();
|
public String getContainingTableName();
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
/*
|
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
|
*
|
||||||
|
* Copyright (c) 2011, 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.metamodel.source.binder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contract describing source of table constraints
|
||||||
|
*
|
||||||
|
* @author Hardy Ferentschik
|
||||||
|
*/
|
||||||
|
public interface UniqueConstraintSource {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return returns the name of the constraint or {@code null} in case a generated name should be used
|
||||||
|
*/
|
||||||
|
public String name();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obtain the logical name of the table for this constraint.
|
||||||
|
*
|
||||||
|
* @return The logical table name. Can be {@code null} in the case of the "primary table".
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public String getTableName();
|
||||||
|
}
|
Loading…
Reference in New Issue