HHH-10045 - Teradata requires non null primary keys.
This commit is contained in:
parent
4777d5888c
commit
e8da2d09b3
|
@ -10,11 +10,42 @@ import java.util.Iterator;
|
|||
import org.hibernate.dialect.Dialect;
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
/**
|
||||
* A primary key constraint
|
||||
*
|
||||
* @author Gavin King
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class PrimaryKey extends Constraint {
|
||||
private static final Logger log = Logger.getLogger( PrimaryKey.class );
|
||||
|
||||
@Override
|
||||
public void addColumn(Column column) {
|
||||
if ( column.isNullable() ) {
|
||||
if ( log.isDebugEnabled() ) {
|
||||
final String columnName = column.getCanonicalName();
|
||||
log.debugf(
|
||||
"Forcing column [%s] to be non-null as it is part of the primary key for table [%s]",
|
||||
columnName,
|
||||
getTableNameForLogging( column )
|
||||
);
|
||||
}
|
||||
column.setNullable( false );
|
||||
}
|
||||
super.addColumn( column );
|
||||
}
|
||||
|
||||
protected String getTableNameForLogging(Column column) {
|
||||
if ( getTable() != null ) {
|
||||
return getTable().getNameIdentifier().getCanonicalName();
|
||||
}
|
||||
else if ( column.getValue() != null && column.getValue().getTable() != null ) {
|
||||
return column.getValue().getTable().getNameIdentifier().getCanonicalName();
|
||||
}
|
||||
return "<unknown>";
|
||||
}
|
||||
|
||||
public String sqlConstraintString(Dialect dialect) {
|
||||
StringBuilder buf = new StringBuilder("primary key (");
|
||||
|
|
Loading…
Reference in New Issue